diff --git a/modules/account_budget/account.py b/modules/account_budget/account.py index 904ce5e62d..5ef7cb3b95 100644 --- a/modules/account_budget/account.py +++ b/modules/account_budget/account.py @@ -10,7 +10,8 @@ from sql.conditionals import Coalesce from trytond import backend from trytond.i18n import gettext from trytond.model import ( - Index, ModelSQL, ModelView, Unique, fields, sequence_ordered, tree) + ChatMixin, Index, ModelSQL, ModelView, Unique, fields, sequence_ordered, + tree) from trytond.modules.account.exceptions import FiscalYearNotFoundError from trytond.modules.currency.fields import Monetary from trytond.pool import Pool @@ -87,7 +88,7 @@ class AmountMixin: raise NotImplementedError -class BudgetMixin: +class BudgetMixin(ChatMixin): __slots__ = () name = fields.Char("Name", required=True) company = fields.Many2One( diff --git a/modules/account_dunning/dunning.py b/modules/account_dunning/dunning.py index f6939fbf14..f42d9b07ea 100644 --- a/modules/account_dunning/dunning.py +++ b/modules/account_dunning/dunning.py @@ -6,7 +6,8 @@ from itertools import groupby from sql import Literal from trytond.model import ( - Index, Model, ModelSQL, ModelView, Unique, fields, sequence_ordered) + ChatMixin, Index, Model, ModelSQL, ModelView, Unique, fields, + sequence_ordered) from trytond.modules.currency.fields import Monetary from trytond.pool import Pool from trytond.pyson import Eval @@ -49,7 +50,7 @@ _STATES = { } -class Dunning(ModelSQL, ModelView): +class Dunning(ModelSQL, ModelView, ChatMixin): __name__ = 'account.dunning' company = fields.Many2One( 'company.company', "Company", required=True, states=_STATES, @@ -303,6 +304,14 @@ class Dunning(ModelSQL, ModelView): level=level, ) + def chat_language(self, audience='internal'): + language = super().chat_language(audience=audience) + if audience == 'public': + language = ( + self.party.lang.code if self.party and self.party.lang + else None) + return language + @classmethod def process(cls, dunnings): pool = Pool() diff --git a/modules/account_invoice/invoice.py b/modules/account_invoice/invoice.py index 3330c04ab7..e07c681f91 100644 --- a/modules/account_invoice/invoice.py +++ b/modules/account_invoice/invoice.py @@ -18,8 +18,8 @@ from stdnum import iso7064, iso11649 from trytond import backend, config from trytond.i18n import gettext from trytond.model import ( - DeactivableMixin, Index, ModelSQL, ModelView, Unique, Workflow, dualmethod, - fields, sequence_ordered) + ChatMixin, DeactivableMixin, Index, ModelSQL, ModelView, Unique, Workflow, + dualmethod, fields, sequence_ordered) from trytond.model.exceptions import AccessError from trytond.modules.account.exceptions import AccountMissing from trytond.modules.account.tax import TaxableMixin @@ -61,7 +61,9 @@ class InvoiceReportMixin: invoice_report_format = fields.Char("Invoice Report Format", readonly=True) -class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin, InvoiceReportMixin): +class Invoice( + Workflow, ModelSQL, ModelView, TaxableMixin, InvoiceReportMixin, + ChatMixin): __name__ = 'account.invoice' _rec_name = 'number' _order_name = 'number' @@ -1531,6 +1533,12 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin, InvoiceReportMixin): return ', '.join(set(filter(None, (l.origin_name for l in self.line_lines)))) + def chat_language(self, audience='internal'): + language = super().chat_language(audience=audience) + if audience == 'public': + language = self.party.lang.code if self.party.lang else None + return language + @classmethod def view_attributes(cls): return super().view_attributes() + [ diff --git a/modules/account_payment/payment.py b/modules/account_payment/payment.py index a65307c026..38536703d3 100644 --- a/modules/account_payment/payment.py +++ b/modules/account_payment/payment.py @@ -13,7 +13,7 @@ from stdnum import iso11649 from trytond import backend from trytond.i18n import gettext from trytond.model import ( - DeactivableMixin, Index, ModelSQL, ModelView, Workflow, fields) + ChatMixin, DeactivableMixin, Index, ModelSQL, ModelView, Workflow, fields) from trytond.model.exceptions import AccessError from trytond.modules.company.model import ( employee_field, reset_employee, set_employee) @@ -62,7 +62,7 @@ class Journal(DeactivableMixin, ModelSQL, ModelView): return Transaction().context.get('company') -class Group(ModelSQL, ModelView): +class Group(ModelSQL, ModelView, ChatMixin): __name__ = 'account.payment.group' _rec_name = 'number' number = fields.Char('Number', required=True, readonly=True) @@ -274,7 +274,7 @@ _STATES = { } -class Payment(Workflow, ModelSQL, ModelView): +class Payment(Workflow, ModelSQL, ModelView, ChatMixin): __name__ = 'account.payment' _rec_name = 'number' number = fields.Char("Number", required=True, readonly=True) @@ -614,6 +614,12 @@ class Payment(Workflow, ModelSQL, ModelView): ('reference', *clause[1:]), ] + def chat_language(self, audience='internal'): + language = super().chat_language(audience=audience) + if audience == 'public': + language = self.party.lang.code if self.party.lang else None + return language + @classmethod def view_attributes(cls): context = Transaction().context diff --git a/modules/account_statement/statement.py b/modules/account_statement/statement.py index 99566d4615..622572e0bf 100644 --- a/modules/account_statement/statement.py +++ b/modules/account_statement/statement.py @@ -13,8 +13,8 @@ from sql.operators import Concat import trytond.config as config from trytond.i18n import gettext from trytond.model import ( - Check, DictSchemaMixin, Index, ModelSQL, ModelView, Workflow, fields, - sequence_ordered) + ChatMixin, Check, DictSchemaMixin, Index, ModelSQL, ModelView, Workflow, + fields, sequence_ordered) from trytond.model.exceptions import AccessError from trytond.modules.company import CompanyReport from trytond.modules.currency.fields import Monetary @@ -49,7 +49,7 @@ class Unequal(object): return '' -class Statement(Workflow, ModelSQL, ModelView): +class Statement(Workflow, ModelSQL, ModelView, ChatMixin): __name__ = 'account.statement' _states = {'readonly': Eval('state') != 'draft'} diff --git a/modules/account_stock_landed_cost/account.py b/modules/account_stock_landed_cost/account.py index 518f19b8b1..99df0ecb09 100644 --- a/modules/account_stock_landed_cost/account.py +++ b/modules/account_stock_landed_cost/account.py @@ -8,7 +8,7 @@ from sql.functions import CharLength from trytond.i18n import gettext from trytond.model import ( - Index, MatchMixin, ModelSQL, ModelView, Workflow, fields) + ChatMixin, Index, MatchMixin, ModelSQL, ModelView, Workflow, fields) from trytond.model.exceptions import AccessError from trytond.modules.company.model import CompanyValueMixin from trytond.modules.product import price_digits, round_price @@ -66,7 +66,7 @@ class ConfigurationLandedCostSequence(ModelSQL, CompanyValueMixin): return None -class LandedCost(Workflow, ModelSQL, ModelView, MatchMixin): +class LandedCost(Workflow, ModelSQL, ModelView, MatchMixin, ChatMixin): __name__ = 'account.landed_cost' _rec_name = 'number' number = fields.Char("Number", readonly=True) diff --git a/modules/account_stock_shipment_cost/account.py b/modules/account_stock_shipment_cost/account.py index 0a7eb120e4..a940d7668b 100644 --- a/modules/account_stock_shipment_cost/account.py +++ b/modules/account_stock_shipment_cost/account.py @@ -6,7 +6,8 @@ from itertools import groupby from sql.functions import CharLength from trytond.i18n import gettext -from trytond.model import Index, ModelSQL, ModelView, Workflow, fields +from trytond.model import ( + ChatMixin, Index, ModelSQL, ModelView, Workflow, fields) from trytond.model.exceptions import AccessError from trytond.modules.company.model import CompanyValueMixin from trytond.modules.product import price_digits, round_price @@ -58,7 +59,7 @@ class ConfigurationShipmentCostSequence(ModelSQL, CompanyValueMixin): return None -class ShipmentCost(Workflow, ModelSQL, ModelView): +class ShipmentCost(Workflow, ModelSQL, ModelView, ChatMixin): __name__ = 'account.shipment_cost' _rec_name = 'number' diff --git a/modules/commission/commission.py b/modules/commission/commission.py index 39b0d20d33..6191735305 100644 --- a/modules/commission/commission.py +++ b/modules/commission/commission.py @@ -15,7 +15,7 @@ from sql.aggregate import Sum from trytond import backend from trytond.i18n import gettext from trytond.model import ( - DeactivableMixin, MatchMixin, ModelSQL, ModelView, fields, + ChatMixin, DeactivableMixin, MatchMixin, ModelSQL, ModelView, fields, sequence_ordered) from trytond.modules.currency.fields import Monetary from trytond.modules.product import price_digits, round_price @@ -337,7 +337,7 @@ class PlanLines(sequence_ordered(), ModelSQL, ModelView, MatchMixin): return super().match(pattern) -class Commission(ModelSQL, ModelView): +class Commission(ModelSQL, ModelView, ChatMixin): __name__ = 'commission' _readonly_states = { 'readonly': Bool(Eval('invoice_line')), @@ -442,6 +442,13 @@ class Commission(ModelSQL, ModelView): state = invoice.state return state + def chat_language(self, audience='internal'): + language = super().chat_language(audience=audience) + if audience == 'public': + language = ( + self.agent.party.lang.code if self.agent.party.lang else None) + return language + @classmethod def copy(cls, commissions, default=None): if default is None: diff --git a/modules/production/production.py b/modules/production/production.py index e4fd1eec4e..c4bd66a61a 100644 --- a/modules/production/production.py +++ b/modules/production/production.py @@ -11,7 +11,7 @@ from sql.functions import CharLength from trytond.i18n import gettext from trytond.model import ( - Index, ModelSQL, ModelView, Workflow, dualmethod, fields) + ChatMixin, Index, ModelSQL, ModelView, Workflow, dualmethod, fields) from trytond.modules.company.model import employee_field, set_employee from trytond.modules.product import price_digits, round_price from trytond.modules.stock.shipment import ShipmentAssignMixin @@ -22,7 +22,8 @@ from trytond.transaction import Transaction from .exceptions import CostWarning -class Production(ShipmentAssignMixin, Workflow, ModelSQL, ModelView): +class Production( + ShipmentAssignMixin, Workflow, ModelSQL, ModelView, ChatMixin): __name__ = 'production' _rec_name = 'number' _assign_moves_field = 'inputs' diff --git a/modules/production_work/work.py b/modules/production_work/work.py index a4cab6c7d8..6203cd2c22 100644 --- a/modules/production_work/work.py +++ b/modules/production_work/work.py @@ -12,7 +12,7 @@ from sql.conditionals import Coalesce from trytond import backend from trytond.i18n import gettext from trytond.model import ( - DeactivableMixin, Index, ModelSQL, ModelView, Workflow, fields, + ChatMixin, DeactivableMixin, Index, ModelSQL, ModelView, Workflow, fields, sequence_ordered, tree) from trytond.model.exceptions import AccessError from trytond.modules.company.model import employee_field, set_employee @@ -99,7 +99,7 @@ class WorkCenter(DeactivableMixin, tree(separator=' / '), ModelSQL, ModelView): return picker -class Work(sequence_ordered(), ModelSQL, ModelView): +class Work(sequence_ordered(), ModelSQL, ModelView, ChatMixin): __name__ = 'production.work' operation = fields.Many2One('production.routing.operation', 'Operation', required=True) diff --git a/modules/project/work.py b/modules/project/work.py index 51c3489652..77ffc8734b 100644 --- a/modules/project/work.py +++ b/modules/project/work.py @@ -7,8 +7,8 @@ from collections import defaultdict from trytond.cache import Cache from trytond.i18n import gettext from trytond.model import ( - DeactivableMixin, Index, ModelSQL, ModelView, fields, sequence_ordered, - sum_tree, tree) + ChatMixin, DeactivableMixin, Index, ModelSQL, ModelView, fields, + sequence_ordered, sum_tree, tree) from trytond.pool import Pool from trytond.pyson import Bool, Eval, If, PYSONEncoder, TimeDelta from trytond.transaction import Transaction @@ -104,7 +104,9 @@ class WorkStatus(DeactivableMixin, sequence_ordered(), ModelSQL, ModelView): return domains -class Work(sequence_ordered(), tree(separator='\\'), ModelSQL, ModelView): +class Work( + sequence_ordered(), tree(separator='\\'), ModelSQL, ModelView, + ChatMixin): __name__ = 'project.work' name = fields.Char("Name", required=True) type = fields.Selection([ @@ -392,6 +394,17 @@ class Work(sequence_ordered(), tree(separator='\\'), ModelSQL, ModelView): int, {w.id: w.effort_hours * (w.progress or 0) for w in works}) + def chat_language(self, audience='internal'): + language = super().chat_language(audience=audience) + if audience == 'public': + work = self + party = self.party + while work and not party: + work = work.parent + party = work.party + language = party.lang.code if party and party.lang else None + return language + @classmethod def copy(cls, project_works, default=None): pool = Pool() diff --git a/modules/purchase/purchase.py b/modules/purchase/purchase.py index 88c664b483..6d9632d1db 100644 --- a/modules/purchase/purchase.py +++ b/modules/purchase/purchase.py @@ -15,7 +15,8 @@ from trytond.i18n import gettext from trytond.ir.attachment import AttachmentCopyMixin from trytond.ir.note import NoteCopyMixin from trytond.model import ( - Index, ModelSQL, ModelView, Unique, Workflow, fields, sequence_ordered) + ChatMixin, Index, ModelSQL, ModelView, Unique, Workflow, fields, + sequence_ordered) from trytond.model.exceptions import AccessError from trytond.modules.account.tax import TaxableMixin from trytond.modules.account_product.exceptions import AccountError @@ -69,7 +70,7 @@ def search_shipments_returns(model_name): class Purchase( Workflow, ModelSQL, ModelView, TaxableMixin, - AttachmentCopyMixin, NoteCopyMixin): + AttachmentCopyMixin, NoteCopyMixin, ChatMixin): __name__ = 'purchase.purchase' _rec_name = 'number' @@ -731,6 +732,12 @@ class Purchase( ]) return attributes + def chat_language(self, audience='internal'): + language = super().chat_language(audience=audience) + if audience == 'public': + language = self.party.lang.code if self.party.lang else None + return language + @classmethod def get_resources_to_copy(cls, name): return { diff --git a/modules/purchase_blanket_agreement/purchase.py b/modules/purchase_blanket_agreement/purchase.py index 1acd197433..05ec3ff9f7 100644 --- a/modules/purchase_blanket_agreement/purchase.py +++ b/modules/purchase_blanket_agreement/purchase.py @@ -9,7 +9,8 @@ from sql import Null from sql.functions import CharLength from trytond.i18n import gettext -from trytond.model import Index, ModelSQL, ModelView, Workflow, fields +from trytond.model import ( + ChatMixin, Index, ModelSQL, ModelView, Workflow, fields) from trytond.modules.currency.fields import Monetary from trytond.modules.product import price_digits, round_price from trytond.modules.product.exceptions import UOMValidationError @@ -106,7 +107,7 @@ class ConfigurationSequence(metaclass=PoolMeta): return None -class BlanketAgreement(Workflow, ModelSQL, ModelView): +class BlanketAgreement(Workflow, ModelSQL, ModelView, ChatMixin): __name__ = 'purchase.blanket_agreement' _rec_name = 'number' @@ -310,6 +311,12 @@ class BlanketAgreement(Workflow, ModelSQL, ModelView): ('reference', operator, value), ] + def chat_language(self, audience='internal'): + language = super().chat_language(audience=audience) + if audience == 'public': + language = self.supplier.lang.code if self.supplier.lang else None + return language + @classmethod def copy(cls, agreements, default=None): default = default.copy() if default is not None else {} diff --git a/modules/purchase_request/purchase_request.py b/modules/purchase_request/purchase_request.py index 796ef3f28a..a443c94db7 100644 --- a/modules/purchase_request/purchase_request.py +++ b/modules/purchase_request/purchase_request.py @@ -5,7 +5,7 @@ from functools import partial from itertools import groupby from trytond.i18n import gettext -from trytond.model import Index, ModelSQL, ModelView, fields +from trytond.model import ChatMixin, Index, ModelSQL, ModelView, fields from trytond.model.exceptions import AccessError from trytond.modules.company.model import ( employee_field, reset_employee, set_employee) @@ -21,7 +21,7 @@ STATES = { } -class PurchaseRequest(ModelSQL, ModelView): +class PurchaseRequest(ModelSQL, ModelView, ChatMixin): __name__ = 'purchase.request' product = fields.Many2One( diff --git a/modules/purchase_request_quotation/purchase.py b/modules/purchase_request_quotation/purchase.py index b200975e37..9ac224ac2a 100644 --- a/modules/purchase_request_quotation/purchase.py +++ b/modules/purchase_request_quotation/purchase.py @@ -9,7 +9,8 @@ from sql.conditionals import Case from sql.functions import CharLength from trytond.i18n import gettext -from trytond.model import Index, ModelSQL, ModelView, Workflow, fields +from trytond.model import ( + ChatMixin, Index, ModelSQL, ModelView, Workflow, fields) from trytond.modules.company import CompanyReport from trytond.modules.currency.fields import Monetary from trytond.modules.product import price_digits @@ -86,7 +87,7 @@ class ConfigurationSequence(metaclass=PoolMeta): return None -class Quotation(Workflow, ModelSQL, ModelView): +class Quotation(Workflow, ModelSQL, ModelView, ChatMixin): __name__ = 'purchase.request.quotation' _rec_name = 'number' @@ -230,6 +231,12 @@ class Quotation(Workflow, ModelSQL, ModelView): if self.supplier: self.supplier_address = self.supplier.address_get() + def chat_language(self, audience='internal'): + language = super().chat_language(audience=audience) + if audience == 'public': + language = self.supplier.lang.code if self.supplier.lang else None + return language + @classmethod def copy(cls, groups, default=None): if default is None: diff --git a/modules/purchase_requisition/purchase.py b/modules/purchase_requisition/purchase.py index 66a5043206..7dda731036 100644 --- a/modules/purchase_requisition/purchase.py +++ b/modules/purchase_requisition/purchase.py @@ -8,7 +8,7 @@ from sql.functions import CharLength from trytond.i18n import gettext from trytond.model import ( - Index, ModelSQL, ModelView, Workflow, fields, sequence_ordered) + ChatMixin, Index, ModelSQL, ModelView, Workflow, fields, sequence_ordered) from trytond.model.exceptions import AccessError, RequiredValidationError from trytond.modules.company.model import ( employee_field, reset_employee, set_employee) @@ -68,7 +68,7 @@ class ConfigurationSequence(metaclass=PoolMeta): return None -class PurchaseRequisition(Workflow, ModelSQL, ModelView): +class PurchaseRequisition(Workflow, ModelSQL, ModelView, ChatMixin): __name__ = 'purchase.requisition' _rec_name = 'number' _states = { diff --git a/modules/quality/quality.py b/modules/quality/quality.py index 91e06dfc3c..0d94474961 100644 --- a/modules/quality/quality.py +++ b/modules/quality/quality.py @@ -9,8 +9,8 @@ from sql.functions import CharLength from trytond.i18n import gettext, lazy_gettext from trytond.model import ( - DeactivableMixin, DictSchemaMixin, MatchMixin, ModelSingleton, ModelSQL, - ModelStorage, ModelView, Unique, Workflow, dualmethod, fields) + ChatMixin, DeactivableMixin, DictSchemaMixin, MatchMixin, ModelSingleton, + ModelSQL, ModelStorage, ModelView, Unique, Workflow, dualmethod, fields) from trytond.model.exceptions import AccessError, ButtonActionException from trytond.modules.company.model import ( CompanyMultiValueMixin, CompanyValueMixin, employee_field, reset_employee, @@ -341,7 +341,7 @@ class ControlPoint(DictSchemaMixin, ModelSQL, ModelView): return result -class Inspection(Workflow, ModelSQL, ModelView): +class Inspection(Workflow, ModelSQL, ModelView, ChatMixin): __name__ = 'quality.inspection' _rec_name = 'number' @@ -608,7 +608,7 @@ class Inspection(Workflow, ModelSQL, ModelView): return cls(control=control, origin=origin) -class Alert(Workflow, ModelSQL, ModelView): +class Alert(Workflow, ModelSQL, ModelView, ChatMixin): __name__ = 'quality.alert' _rec_name = 'number' diff --git a/modules/sale/sale.py b/modules/sale/sale.py index fd232ce2ab..0db85d9aed 100644 --- a/modules/sale/sale.py +++ b/modules/sale/sale.py @@ -16,7 +16,8 @@ from trytond.i18n import gettext from trytond.ir.attachment import AttachmentCopyMixin from trytond.ir.note import NoteCopyMixin from trytond.model import ( - Index, ModelSQL, ModelView, Unique, Workflow, fields, sequence_ordered) + ChatMixin, Index, ModelSQL, ModelView, Unique, Workflow, fields, + sequence_ordered) from trytond.model.exceptions import AccessError from trytond.modules.account.tax import TaxableMixin from trytond.modules.account_product.exceptions import AccountError @@ -71,7 +72,7 @@ def search_shipments_returns(model_name): class Sale( Workflow, ModelSQL, ModelView, TaxableMixin, - AttachmentCopyMixin, NoteCopyMixin): + AttachmentCopyMixin, NoteCopyMixin, ChatMixin): __name__ = 'sale.sale' _rec_name = 'number' company = fields.Many2One( @@ -878,6 +879,12 @@ class Sale( ]) return attributes + def chat_language(self, audience='internal'): + language = super().chat_language(audience=audience) + if audience == 'public': + language = self.party.lang.code if self.party.lang else None + return language + @classmethod def get_resources_to_copy(cls, name): return { diff --git a/modules/sale_blanket_agreement/sale.py b/modules/sale_blanket_agreement/sale.py index 6d6c39b930..ba43d104b5 100644 --- a/modules/sale_blanket_agreement/sale.py +++ b/modules/sale_blanket_agreement/sale.py @@ -9,7 +9,8 @@ from sql import Null from sql.functions import CharLength from trytond.i18n import gettext -from trytond.model import Index, ModelSQL, ModelView, Workflow, fields +from trytond.model import ( + ChatMixin, Index, ModelSQL, ModelView, Workflow, fields) from trytond.modules.currency.fields import Monetary from trytond.modules.product import price_digits, round_price from trytond.modules.product.exceptions import UOMValidationError @@ -106,7 +107,7 @@ class ConfigurationSequence(metaclass=PoolMeta): return None -class BlanketAgreement(Workflow, ModelSQL, ModelView): +class BlanketAgreement(Workflow, ModelSQL, ModelView, ChatMixin): __name__ = 'sale.blanket_agreement' _rec_name = 'number' @@ -311,6 +312,12 @@ class BlanketAgreement(Workflow, ModelSQL, ModelView): ('reference', operator, value), ] + def chat_language(self, audience='internal'): + language = super().chat_language(audience=audience) + if audience == 'public': + language = self.customer.lang.code if self.customer.lang else None + return language + @classmethod def copy(cls, agreements, default=None): default = default.copy() if default is not None else {} diff --git a/modules/sale_complaint/complaint.py b/modules/sale_complaint/complaint.py index c921f3fa02..21094680cb 100644 --- a/modules/sale_complaint/complaint.py +++ b/modules/sale_complaint/complaint.py @@ -10,7 +10,7 @@ from sql.functions import CharLength from trytond.i18n import gettext from trytond.model import ( - DeactivableMixin, Index, ModelSQL, ModelView, Workflow, fields) + ChatMixin, DeactivableMixin, Index, ModelSQL, ModelView, Workflow, fields) from trytond.model.exceptions import AccessError from trytond.modules.company.model import ( employee_field, reset_employee, set_employee) @@ -34,7 +34,7 @@ class Type(DeactivableMixin, ModelSQL, ModelView): 'account.invoice', 'account.invoice.line'])]) -class Complaint(Workflow, ModelSQL, ModelView): +class Complaint(Workflow, ModelSQL, ModelView, ChatMixin): __name__ = 'sale.complaint' _rec_name = 'number' @@ -278,6 +278,12 @@ class Complaint(Workflow, ModelSQL, ModelView): ('/tree', 'visual', If(Eval('state') == 'cancelled', 'muted', '')), ] + def chat_language(self, audience='internal'): + language = super().chat_language(audience=audience) + if audience == 'public': + language = self.customer.lang.code if self.customer.lang else None + return language + @classmethod def preprocess_values(cls, mode, values): pool = Pool() diff --git a/modules/sale_opportunity/opportunity.py b/modules/sale_opportunity/opportunity.py index 4ab3a72e1e..bb90d51a2b 100644 --- a/modules/sale_opportunity/opportunity.py +++ b/modules/sale_opportunity/opportunity.py @@ -10,7 +10,7 @@ from trytond.i18n import gettext from trytond.ir.attachment import AttachmentCopyMixin from trytond.ir.note import NoteCopyMixin from trytond.model import ( - Index, ModelSQL, ModelView, Workflow, fields, sequence_ordered) + ChatMixin, Index, ModelSQL, ModelView, Workflow, fields, sequence_ordered) from trytond.model.exceptions import AccessError from trytond.modules.company.model import employee_field, set_employee from trytond.modules.currency.fields import Monetary @@ -22,7 +22,7 @@ from trytond.transaction import Transaction class SaleOpportunity( Workflow, ModelSQL, ModelView, - AttachmentCopyMixin, NoteCopyMixin): + AttachmentCopyMixin, NoteCopyMixin, ChatMixin): __name__ = "sale.opportunity" _history = True _rec_name = 'number' @@ -293,6 +293,12 @@ class SaleOpportunity( ('/tree', 'visual', If(Eval('state') == 'cancelled', 'muted', '')), ] + def chat_language(self, audience='internal'): + language = super().chat_language(audience=audience) + if audience == 'public': + language = self.party.lang.code if self.party.lang else None + return language + @classmethod def get_resources_to_copy(cls, name): return { diff --git a/modules/sale_point/sale.py b/modules/sale_point/sale.py index 6e9a685efc..d393c89ee4 100644 --- a/modules/sale_point/sale.py +++ b/modules/sale_point/sale.py @@ -13,7 +13,8 @@ from sql.operators import Equal from trytond import backend from trytond.i18n import gettext from trytond.model import ( - DeactivableMixin, Exclude, Index, ModelSQL, ModelView, Workflow, fields) + ChatMixin, DeactivableMixin, Exclude, Index, ModelSQL, ModelView, Workflow, + fields) from trytond.model.exceptions import AccessError from trytond.modules.account.tax import TaxableMixin from trytond.modules.currency.fields import Monetary @@ -92,7 +93,7 @@ class POS(ModelSQL, ModelView): 'msg_point_change_tax_included')) -class POSSale(Workflow, ModelSQL, ModelView, TaxableMixin): +class POSSale(Workflow, ModelSQL, ModelView, TaxableMixin, ChatMixin): __name__ = 'sale.point.sale' _rec_name = 'number' diff --git a/modules/sale_rental/sale.py b/modules/sale_rental/sale.py index 7fa5a7b00e..bdb06dec62 100644 --- a/modules/sale_rental/sale.py +++ b/modules/sale_rental/sale.py @@ -9,8 +9,8 @@ from trytond.i18n import gettext from trytond.ir.attachment import AttachmentCopyMixin from trytond.ir.note import NoteCopyMixin from trytond.model import ( - Index, ModelSQL, ModelView, Unique, Workflow, dualmethod, fields, - sequence_ordered) + ChatMixin, Index, ModelSQL, ModelView, Unique, Workflow, dualmethod, + fields, sequence_ordered) from trytond.model.exceptions import AccessError, ValidationError from trytond.model.fields.date import FormatMixin from trytond.modules.account.tax import TaxableMixin @@ -121,7 +121,7 @@ class ConfigurationSequence(metaclass=PoolMeta): class Rental( Workflow, ModelSQL, ModelView, TaxableMixin, - AttachmentCopyMixin, NoteCopyMixin): + AttachmentCopyMixin, NoteCopyMixin, ChatMixin): __name__ = 'sale.rental' _rec_name = 'number' @@ -606,6 +606,12 @@ class Rental( ] return domain + def chat_language(self, audience='internal'): + language = super().chat_language(audience=audience) + if audience == 'public': + language = self.party.lang.code if self.party.lang else None + return language + @classmethod def copy(cls, rentals, default=None): default = default.copy() if default is not None else {} diff --git a/modules/sale_subscription/subscription.py b/modules/sale_subscription/subscription.py index 80f65469dc..52f49dc039 100644 --- a/modules/sale_subscription/subscription.py +++ b/modules/sale_subscription/subscription.py @@ -9,7 +9,7 @@ from sql.functions import CharLength from trytond.i18n import gettext from trytond.model import ( - Index, ModelSQL, ModelView, Workflow, fields, sequence_ordered) + ChatMixin, Index, ModelSQL, ModelView, Workflow, fields, sequence_ordered) from trytond.model.exceptions import AccessError from trytond.modules.company.model import ( employee_field, reset_employee, set_employee) @@ -25,7 +25,7 @@ from trytond.wizard import ( from .exceptions import InvalidRecurrence, InvoiceError -class Subscription(Workflow, ModelSQL, ModelView): +class Subscription(Workflow, ModelSQL, ModelView, ChatMixin): __name__ = 'sale.subscription' _rec_name = 'number' @@ -335,6 +335,12 @@ class Subscription(Workflow, ModelSQL, ModelView): ] return domain + def chat_language(self, audience='internal'): + language = super().chat_language(audience=audience) + if audience == 'public': + language = self.party.lang.code if self.party.lang else None + return language + @classmethod def copy(cls, subscriptions, default=None): if default is None: diff --git a/modules/stock/inventory.py b/modules/stock/inventory.py index fb8fddfac8..921306ad59 100644 --- a/modules/stock/inventory.py +++ b/modules/stock/inventory.py @@ -7,7 +7,7 @@ from sql.functions import CharLength from trytond.i18n import gettext from trytond.model import ( - Check, Index, Model, ModelSQL, ModelView, Workflow, fields) + ChatMixin, Check, Index, Model, ModelSQL, ModelView, Workflow, fields) from trytond.model.exceptions import AccessError from trytond.pool import Pool from trytond.pyson import Bool, Eval, If @@ -19,7 +19,7 @@ from .exceptions import ( InventoryCountWarning, InventoryFutureWarning, InventoryValidationError) -class Inventory(Workflow, ModelSQL, ModelView): +class Inventory(Workflow, ModelSQL, ModelView, ChatMixin): __name__ = 'stock.inventory' _rec_name = 'number' diff --git a/modules/stock/shipment.py b/modules/stock/shipment.py index 4934bf38cb..83a40437e8 100644 --- a/modules/stock/shipment.py +++ b/modules/stock/shipment.py @@ -11,7 +11,7 @@ from sql.functions import CharLength from trytond.i18n import gettext, lazy_gettext from trytond.model import ( - Index, ModelSQL, ModelView, Workflow, dualmethod, fields, sort) + ChatMixin, Index, ModelSQL, ModelView, Workflow, dualmethod, fields, sort) from trytond.model.exceptions import AccessError from trytond.modules.company import CompanyReport from trytond.modules.company.model import employee_field, set_employee @@ -344,7 +344,8 @@ class ShipmentCheckQuantity: class ShipmentIn( - ShipmentCheckQuantity, ShipmentMixin, Workflow, ModelSQL, ModelView): + ShipmentCheckQuantity, ShipmentMixin, Workflow, ModelSQL, ModelView, + ChatMixin): __name__ = 'stock.shipment.in' company = fields.Many2One( @@ -658,6 +659,12 @@ class ShipmentIn( return ', '.join(set(filter(None, (m.origin_name for m in self.incoming_moves)))) + def chat_language(self, audience='internal'): + language = super().chat_language(audience=audience) + if audience == 'public': + language = self.supplier.lang.code if self.supplier.lang else None + return language + @classmethod def preprocess_values(cls, mode, values): pool = Pool() @@ -789,7 +796,8 @@ class ShipmentIn( return self.inventory_moves -class ShipmentInReturn(ShipmentAssignMixin, Workflow, ModelSQL, ModelView): +class ShipmentInReturn( + ShipmentAssignMixin, Workflow, ModelSQL, ModelView, ChatMixin): __name__ = 'stock.shipment.in.return' _assign_moves_field = 'moves' @@ -983,6 +991,12 @@ class ShipmentInReturn(ShipmentAssignMixin, Workflow, ModelSQL, ModelView): return ', '.join(set(filter(None, (m.origin_name for m in self.moves)))) + def chat_language(self, audience='internal'): + language = super().chat_language(audience=audience) + if audience == 'public': + language = self.supplier.lang.code if self.supplier.lang else None + return language + @classmethod def copy(cls, shipments, default=None): if default is None: @@ -1117,7 +1131,7 @@ class ShipmentInReturn(ShipmentAssignMixin, Workflow, ModelSQL, ModelView): class ShipmentOut( ShipmentCheckQuantity, ShipmentAssignMixin, Workflow, ModelSQL, - ModelView): + ModelView, ChatMixin): __name__ = 'stock.shipment.out' _assign_moves_field = 'moves' company = fields.Many2One( @@ -1453,6 +1467,12 @@ class ShipmentOut( return ', '.join(set(filter(None, (m.origin_name for m in self.outgoing_moves)))) + def chat_language(self, audience='internal'): + language = super().chat_language(audience=audience) + if audience == 'public': + language = self.customer.lang.code if self.customer.lang else None + return language + @classmethod @ModelView.button @Workflow.transition('draft') @@ -1814,7 +1834,8 @@ class ShipmentOut( class ShipmentOutReturn( - ShipmentCheckQuantity, ShipmentMixin, Workflow, ModelSQL, ModelView): + ShipmentCheckQuantity, ShipmentMixin, Workflow, ModelSQL, ModelView, + ChatMixin): __name__ = 'stock.shipment.out.return' company = fields.Many2One( @@ -2108,6 +2129,12 @@ class ShipmentOutReturn( return ', '.join(set(filter(None, (m.origin_name for m in self.incoming_moves)))) + def chat_language(self, audience='internal'): + language = super().chat_language(audience=audience) + if audience == 'public': + language = self.customer.lang.code if self.customer.lang else None + return language + @classmethod def preprocess_values(cls, mode, values): pool = Pool() @@ -2238,7 +2265,7 @@ class ShipmentOutReturn( class ShipmentInternal( ShipmentCheckQuantity, ShipmentAssignMixin, Workflow, ModelSQL, - ModelView): + ModelView, ChatMixin): __name__ = 'stock.shipment.internal' _assign_moves_field = 'moves' effective_start_date = fields.Date('Effective Start Date', diff --git a/modules/stock_forecast/forecast.py b/modules/stock_forecast/forecast.py index 38c3bd4836..7a0cf9fe83 100644 --- a/modules/stock_forecast/forecast.py +++ b/modules/stock_forecast/forecast.py @@ -12,7 +12,7 @@ from sql.operators import Equal from trytond.i18n import gettext from trytond.model import ( - Exclude, Index, ModelSQL, ModelView, Unique, Workflow, fields) + ChatMixin, Exclude, Index, ModelSQL, ModelView, Unique, Workflow, fields) from trytond.model.exceptions import AccessError from trytond.pool import Pool from trytond.pyson import Bool, Eval, If @@ -23,7 +23,7 @@ from trytond.transaction import Transaction from trytond.wizard import Button, StateTransition, StateView, Wizard -class Forecast(Workflow, ModelSQL, ModelView): +class Forecast(Workflow, ModelSQL, ModelView, ChatMixin): __name__ = "stock.forecast" _states = {