diff options
| author | Prakash Prajapati <ppr@odoo.com> | 2019-07-30 11:26:58 +0000 |
|---|---|---|
| committer | Yannick Tivisse <yti@odoo.com> | 2019-08-16 11:17:28 +0000 |
| commit | c058562d7301298fd71b2618b5386611dfeb81cb (patch) | |
| tree | 33e415704316c3da0ec08b4dd3168bdec9bca8d6 | |
| parent | 25714692b23624d04a43862db26ebcf802b89399 (diff) | |
[IMP] various: Add multi company domains on views
When the many2xxx field relates to a model where company_id is required, set
this domain [('company_id','=',company_id.id)]
When the company_id field of the related model is not required, set this domain
['|',('company_id','=',company_id.id),('company_id','=',False)]
When setting the domain on a field which is in the treeview of a xxx2many field
evaluate against the company_id of the 'parent'.
Some constraints have been added on sereval models. Take a look at the complete
specification for more details.
TaskID: 2024446
Closes: #35266
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
67 files changed, 170 insertions, 134 deletions
diff --git a/addons/account/models/account.py b/addons/account/models/account.py index 0880d9b06e1..05b858688b2 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -515,7 +515,7 @@ class AccountJournalGroup(models.Model): name = fields.Char("Group Name", required=True, translate=True) company_id = fields.Many2one('res.company', required=True, default=lambda self: self.env.company) - account_journal_ids = fields.Many2many('account.journal', string="Journals") + account_journal_ids = fields.Many2many('account.journal', string="Journals", domain="[('company_id', '=', company_id)]") sequence = fields.Integer(default=10) @@ -553,11 +553,11 @@ class AccountJournal(models.Model): "Select 'General' for miscellaneous operations journals.") type_control_ids = fields.Many2many('account.account.type', 'account_journal_type_rel', 'journal_id', 'type_id', string='Account Types Allowed') account_control_ids = fields.Many2many('account.account', 'account_account_type_rel', 'journal_id', 'account_id', string='Accounts Allowed', - domain=[('deprecated', '=', False)]) + domain="[('deprecated', '=', False), ('company_id', '=', company_id)]") default_credit_account_id = fields.Many2one('account.account', string='Default Credit Account', domain=[('deprecated', '=', False)], help="It acts as a default account for credit amount") default_debit_account_id = fields.Many2one('account.account', string='Default Debit Account', - domain=[('deprecated', '=', False)], help="It acts as a default account for debit amount") + domain="[('deprecated', '=', False), ('company_id', '=', company_id)]", help="It acts as a default account for debit amount") update_posted = fields.Boolean(string='Allow Cancelling Entries', help="Check this box if you want to allow the cancellation the entries related to this journal or of the invoice related to this journal") sequence_id = fields.Many2one('ir.sequence', string='Entry Sequence', @@ -596,14 +596,14 @@ class AccountJournal(models.Model): "SEPA Credit Transfer: Pay bill from a SEPA Credit Transfer file you submit to your bank. Enable this option from the settings.") at_least_one_inbound = fields.Boolean(compute='_methods_compute', store=True) at_least_one_outbound = fields.Boolean(compute='_methods_compute', store=True) - profit_account_id = fields.Many2one('account.account', string='Profit Account', help="Used to register a profit when the ending balance of a cash register differs from what the system computes") - loss_account_id = fields.Many2one('account.account', string='Loss Account', help="Used to register a loss when the ending balance of a cash register differs from what the system computes") + profit_account_id = fields.Many2one('account.account', domain="[('company_id', '=', company_id)]", string='Profit Account', help="Used to register a profit when the ending balance of a cash register differs from what the system computes") + loss_account_id = fields.Many2one('account.account', domain="[('company_id', '=', company_id)]", string='Loss Account', help="Used to register a loss when the ending balance of a cash register differs from what the system computes") belongs_to_company = fields.Boolean('Belong to the user\'s current company', compute="_belong_to_company", search="_search_company_journals",) # Bank journals fields company_partner_id = fields.Many2one('res.partner', related='company_id.partner_id', string='Account Holder', readonly=True, store=False) - bank_account_id = fields.Many2one('res.partner.bank', string="Bank Account", ondelete='restrict', copy=False, domain="[('partner_id','=', company_partner_id)]") + bank_account_id = fields.Many2one('res.partner.bank', string="Bank Account", ondelete='restrict', copy=False, domain="[('partner_id','=', company_partner_id), '|', ('company_id', '=', False), ('company_id', '=', company_id)]") bank_statements_source = fields.Selection(selection=_get_bank_statements_available_sources, string='Bank Feeds', default='undefined', help="Defines how the bank statements will be registered") bank_acc_number = fields.Char(related='bank_account_id.acc_number', readonly=False) bank_id = fields.Many2one('res.bank', related='bank_account_id.bank_id', readonly=False) @@ -614,7 +614,7 @@ class AccountJournal(models.Model): alias_domain = fields.Char('Alias domain', compute='_compute_alias_domain', default=lambda self: self.env["ir.config_parameter"].sudo().get_param("mail.catchall.domain")) alias_name = fields.Char('Alias Name', related='alias_id.alias_name', help="It creates draft invoices and bills by sending an email.", readonly=False) - journal_group_ids = fields.Many2many('account.journal.group', string="Journal Groups") + journal_group_ids = fields.Many2many('account.journal.group', domain="[('company_id', '=', company_id)]", string="Journal Groups") _sql_constraints = [ ('code_company_uniq', 'unique (code, name, company_id)', 'The code and name of the journal must be unique per company !'), diff --git a/addons/account/models/account_analytic_line.py b/addons/account/models/account_analytic_line.py index 9a7235ac9a0..60e80ab015a 100644 --- a/addons/account/models/account_analytic_line.py +++ b/addons/account/models/account_analytic_line.py @@ -9,7 +9,7 @@ class AccountAnalyticLine(models.Model): _description = 'Analytic Line' _order = 'date desc' - product_id = fields.Many2one('product.product', string='Product') + product_id = fields.Many2one('product.product', string='Product', domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") general_account_id = fields.Many2one('account.account', string='Financial Account', ondelete='restrict', readonly=True, related='move_id.account_id', store=True, domain=[('deprecated', '=', False)], compute_sudo=True) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index cf60e5b78af..415225ac374 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -102,7 +102,7 @@ class AccountMove(models.Model): help='If this checkbox is ticked, it means that the user was not sure of all the related informations at the time of the creation of the move and that the move needs to be checked again.') journal_id = fields.Many2one('account.journal', string='Journal', required=True, readonly=True, states={'draft': [('readonly', False)]}, - domain=lambda self: [('company_id', '=', self.env.company.id)], + domain="[('company_id', '=', company_id)]", default=_get_default_journal) company_id = fields.Many2one(string='Company', store=True, readonly=True, related='journal_id.company_id') @@ -116,6 +116,7 @@ class AccountMove(models.Model): states={'draft': [('readonly', False)]}) partner_id = fields.Many2one('res.partner', readonly=True, tracking=True, states={'draft': [('readonly', False)]}, + domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", string='Customer/Vendor') commercial_partner_id = fields.Many2one('res.partner', string='Commercial Entity', store=True, readonly=True, compute='_compute_commercial_partner_id') @@ -163,6 +164,7 @@ class AccountMove(models.Model): # ==== Business fields ==== fiscal_position_id = fields.Many2one('account.fiscal.position', string='Fiscal Position', readonly=True, states={'draft': [('readonly', False)]}, + domain="[('company_id', '=', company_id)]", help="Fiscal positions are used to adapt taxes and accounts for particular customers or sales orders/invoices. " "The default value comes from the customer.") invoice_user_id = fields.Many2one('res.users', readonly=True, copy=False, tracking=True, @@ -194,6 +196,7 @@ class AccountMove(models.Model): help="The document(s) that generated the invoice.") invoice_payment_term_id = fields.Many2one('account.payment.term', string='Payment Terms', readonly=True, states={'draft': [('readonly', False)]}, + domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", help="If you use payment terms, the due date will be computed automatically at the generation " "of accounting entries. If you keep the payment terms and the due date empty, it means direct payment. " "The payment terms may compute several due dates, for example 50% now, 50% in one month.") @@ -204,7 +207,7 @@ class AccountMove(models.Model): states={'draft': [('readonly', False)]}) invoice_partner_bank_id = fields.Many2one('res.partner.bank', string='Bank Account', help='Bank Account Number to which the invoice will be paid. A Company bank account if this is a Customer Invoice or Vendor Credit Note, otherwise a Partner bank account number.', - readonly=True, states={'draft': [('readonly', False)]}) + readonly=True, states={'draft': [('readonly', False)]}, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") invoice_incoterm_id = fields.Many2one('account.incoterms', string='Incoterm', default=_get_default_invoice_incoterm, help='International Commercial Terms are a series of predefined commercial terms used in international transactions.') @@ -219,6 +222,7 @@ class AccountMove(models.Model): # ==== Vendor bill fields ==== invoice_vendor_bill_id = fields.Many2one('account.move', store=False, + domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", string='Vendor Bill', help="Auto-complete from a past bill.") invoice_source_email = fields.Char(string='Source Email', tracking=True) diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py index 27f0a07fd3a..4e813b65f72 100644 --- a/addons/account/models/account_payment.py +++ b/addons/account/models/account_payment.py @@ -39,7 +39,7 @@ class account_payment(models.Model): # Money flows from the journal_id's default_debit_account_id or default_credit_account_id to the destination_account_id destination_account_id = fields.Many2one('account.account', compute='_compute_destination_account_id', readonly=True) # For money transfer, money goes from journal_id to a transfer account, then from the transfer account to destination_journal_id - destination_journal_id = fields.Many2one('account.journal', string='Transfer To', domain=[('type', 'in', ('bank', 'cash'))], readonly=True, states={'draft': [('readonly', False)]}) + destination_journal_id = fields.Many2one('account.journal', string='Transfer To', domain="[('type', 'in', ('bank', 'cash')), ('company_id', '=', company_id)]", readonly=True, states={'draft': [('readonly', False)]}) invoice_ids = fields.Many2many('account.move', 'account_invoice_payment_rel', 'payment_id', 'invoice_id', string="Invoices", copy=False, readonly=True, help="""Technical field containing the invoice for which the payment has been generated. @@ -63,13 +63,13 @@ class account_payment(models.Model): help="Technical field used to adapt the interface to the payment type selected.", readonly=True) partner_type = fields.Selection([('customer', 'Customer'), ('supplier', 'Vendor')], tracking=True, readonly=True, states={'draft': [('readonly', False)]}) - partner_id = fields.Many2one('res.partner', string='Partner', tracking=True, readonly=True, states={'draft': [('readonly', False)]}) + partner_id = fields.Many2one('res.partner', string='Partner', tracking=True, readonly=True, states={'draft': [('readonly', False)]}, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") amount = fields.Monetary(string='Payment Amount', required=True, readonly=True, states={'draft': [('readonly', False)]}, tracking=True) currency_id = fields.Many2one('res.currency', string='Currency', required=True, readonly=True, states={'draft': [('readonly', False)]}, default=lambda self: self.env.company.currency_id) payment_date = fields.Date(string='Payment Date', default=fields.Date.context_today, required=True, readonly=True, states={'draft': [('readonly', False)]}, copy=False, tracking=True) communication = fields.Char(string='Memo', readonly=True, states={'draft': [('readonly', False)]}) - journal_id = fields.Many2one('account.journal', string='Payment Journal', required=True, readonly=True, states={'draft': [('readonly', False)]}, tracking=True, domain=[('type', 'in', ('bank', 'cash'))]) + journal_id = fields.Many2one('account.journal', string='Payment Journal', required=True, readonly=True, states={'draft': [('readonly', False)]}, tracking=True, domain="[('type', 'in', ('bank', 'cash')), ('company_id', '=', company_id)]") company_id = fields.Many2one('res.company', related='journal_id.company_id', string='Company', readonly=True) hide_payment_method = fields.Boolean(compute='_compute_hide_payment_method', @@ -78,12 +78,12 @@ class account_payment(models.Model): payment_difference = fields.Monetary(compute='_compute_payment_difference', readonly=True) payment_difference_handling = fields.Selection([('open', 'Keep open'), ('reconcile', 'Mark invoice as fully paid')], default='open', string="Payment Difference Handling", copy=False) - writeoff_account_id = fields.Many2one('account.account', string="Difference Account", domain=[('deprecated', '=', False)], copy=False) + writeoff_account_id = fields.Many2one('account.account', string="Difference Account", domain="[('deprecated', '=', False), ('company_id', '=', company_id)]", copy=False) writeoff_label = fields.Char( string='Journal Item Label', help='Change label of the counterpart that will hold the payment difference', default='Write-Off') - partner_bank_account_id = fields.Many2one('res.partner.bank', string="Recipient Bank Account", readonly=True, states={'draft': [('readonly', False)]}) + partner_bank_account_id = fields.Many2one('res.partner.bank', string="Recipient Bank Account", readonly=True, states={'draft': [('readonly', False)]}, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") show_partner_bank_account = fields.Boolean(compute='_compute_show_partner_bank', help='Technical field used to know whether the field `partner_bank_account_id` needs to be displayed or not in the payments form views') require_partner_bank_account = fields.Boolean(compute='_compute_show_partner_bank', help='Technical field used to know whether the field `partner_bank_account_id` needs to be required or not in the payments form views') diff --git a/addons/account/models/partner.py b/addons/account/models/partner.py index bf94a871a66..03c615c58a0 100644 --- a/addons/account/models/partner.py +++ b/addons/account/models/partner.py @@ -18,7 +18,7 @@ class AccountFiscalPosition(models.Model): name = fields.Char(string='Fiscal Position', required=True) active = fields.Boolean(default=True, help="By unchecking the active field, you may hide a fiscal position without deleting it.") - company_id = fields.Many2one('res.company', string='Company') + company_id = fields.Many2one('res.company', string='Company', default=lambda self: self.env.company, required=True) account_ids = fields.One2many('account.fiscal.position.account', 'position_id', string='Account Mapping', copy=True) tax_ids = fields.One2many('account.fiscal.position.tax', 'position_id', string='Tax Mapping', copy=True) note = fields.Text('Notes', translate=True, help="Legal mentions that have to be printed on the invoices.") diff --git a/addons/account/views/account_move_views.xml b/addons/account/views/account_move_views.xml index 61609d1fea6..3f1ebebc8cb 100644 --- a/addons/account/views/account_move_views.xml +++ b/addons/account/views/account_move_views.xml @@ -622,15 +622,17 @@ <!-- Displayed fields --> <field name="sequence" widget="handle"/> - <field name="product_id"/> + <field name="product_id" domain="['|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]"/> <field name="name" widget="section_and_note_text" required="1"/> <field name="account_id" groups="account.group_account_user" - domain="[('deprecated', '=', False), ('user_type_id.type', 'not in', ('receivable', 'payable'))]" + domain="[('deprecated', '=', False), ('user_type_id.type', 'not in', ('receivable', 'payable')), ('company_id', '=', parent.company_id)]" attrs="{'required': [('display_type', '=', False)]}"/> <field name="analytic_account_id" + domain="['|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]" groups="analytic.group_analytic_accounting"/> <field name="analytic_tag_ids" + domain="['|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]" groups="analytic.group_analytic_tags" widget="many2many_tags"/> <field name="quantity"/> @@ -638,7 +640,7 @@ <field name="price_unit" string="Price"/> <field name="discount" string="Disc.%" groups="base.group_no_one"/> <field name="tax_ids" widget="many2many_tags" - domain="[('type_tax_use', '=?', parent.invoice_filter_type_domain)]" + domain="[('type_tax_use', '=?', parent.invoice_filter_type_domain), ('company_id', '=', parent.company_id)]" context="{'append_type_to_tax_name': not parent.invoice_filter_type_domain}" options="{'no_create': True}"/> <field name="price_subtotal" @@ -822,6 +824,9 @@ <field name="reversed_entry_id" attrs="{'invisible': [('type', '!=', 'entry')]}"/> </group> + <group> + <field name="company_id" groups="base.group_multi_company" required="1"/> + </group> </group> </page> </notebook> diff --git a/addons/account/views/account_payment_view.xml b/addons/account/views/account_payment_view.xml index 64cbfd929aa..6cc672d4f24 100644 --- a/addons/account/views/account_payment_view.xml +++ b/addons/account/views/account_payment_view.xml @@ -171,6 +171,9 @@ <field name="require_partner_bank_account" invisible="1"/> <field name="payment_method_code" invisible="1"/> </group> + <group> + <field name="company_id" groups="base.group_multi_company" required="1"/> + </group> <group attrs="{'invisible': [('payment_difference', '=', 0.0)]}"> <label for="payment_difference"/> <div> diff --git a/addons/account/views/account_view.xml b/addons/account/views/account_view.xml index dab7c49efb8..c735c8ccddc 100644 --- a/addons/account/views/account_view.xml +++ b/addons/account/views/account_view.xml @@ -199,6 +199,7 @@ <field name="name"/> <field name="account_journal_ids" widget="many2many_tags" options="{'no_create': True}"/> <field name="sequence"/> + <field name="company_id" groups="base.group_multi_company"/> </group> </sheet> </form> diff --git a/addons/account/views/partner_view.xml b/addons/account/views/partner_view.xml index 251b855ab81..9b90e8fec88 100644 --- a/addons/account/views/partner_view.xml +++ b/addons/account/views/partner_view.xml @@ -39,8 +39,8 @@ <group> <field name="tax_ids" widget="one2many" nolabel="1" context="{'append_type_to_tax_name': True}"> <tree name="tax_map_tree" string="Tax Mapping" editable="bottom"> - <field name="tax_src_id" domain="[('type_tax_use', '!=', None)]" context="{'append_type_to_tax_name': True}"/> - <field name="tax_dest_id" domain="[('type_tax_use', '!=', None)]" context="{'append_type_to_tax_name': True}"/> + <field name="tax_src_id" domain="[('type_tax_use', '!=', None), '|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]" context="{'append_type_to_tax_name': True}"/> + <field name="tax_dest_id" domain="[('type_tax_use', '!=', None), '|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]" context="{'append_type_to_tax_name': True}"/> </tree> <form name="tax_map_form" string="Tax Mapping"> <group> @@ -55,12 +55,12 @@ <group> <field name="account_ids" widget="one2many" nolabel="1"> <tree string="Account Mapping" editable="bottom"> - <field name="account_src_id"/> - <field name="account_dest_id"/> + <field name="account_src_id" domain="['|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]"/> + <field name="account_dest_id" domain="['|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]"/> </tree> <form string="Account Mapping"> - <field name="account_src_id"/> - <field name="account_dest_id"/> + <field name="account_src_id" domain="['|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]"/> + <field name="account_dest_id" domain="['|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]"/> </form> </field> </group> diff --git a/addons/analytic/models/analytic_account.py b/addons/analytic/models/analytic_account.py index 310a999c99d..2ec45c72f73 100644 --- a/addons/analytic/models/analytic_account.py +++ b/addons/analytic/models/analytic_account.py @@ -40,11 +40,11 @@ class AccountAnalyticGroup(models.Model): name = fields.Char(required=True) description = fields.Text(string='Description') - parent_id = fields.Many2one('account.analytic.group', string="Parent", ondelete='cascade') + parent_id = fields.Many2one('account.analytic.group', string="Parent", ondelete='cascade', domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") parent_path = fields.Char(index=True) children_ids = fields.One2many('account.analytic.group', 'parent_id', string="Childrens") complete_name = fields.Char('Complete Name', compute='_compute_complete_name', store=True) - company_id = fields.Many2one('res.company', string='Company') + company_id = fields.Many2one('res.company', string='Company', default=lambda self: self.env.company) @api.depends('name', 'parent_id.complete_name') def _compute_complete_name(self): @@ -124,14 +124,14 @@ class AccountAnalyticAccount(models.Model): code = fields.Char(string='Reference', index=True, tracking=True) active = fields.Boolean('Active', help="If the active field is set to False, it will allow you to hide the account without removing it.", default=True) - group_id = fields.Many2one('account.analytic.group', string='Group') + group_id = fields.Many2one('account.analytic.group', string='Group', domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") line_ids = fields.One2many('account.analytic.line', 'account_id', string="Analytic Lines") company_id = fields.Many2one('res.company', string='Company', default=lambda self: self.env.company) # use auto_join to speed up name_search call - partner_id = fields.Many2one('res.partner', string='Customer', auto_join=True, tracking=True) + partner_id = fields.Many2one('res.partner', string='Customer', auto_join=True, tracking=True, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") balance = fields.Monetary(compute='_compute_debit_credit_balance', string='Balance') debit = fields.Monetary(compute='_compute_debit_credit_balance', string='Debit') @@ -181,10 +181,10 @@ class AccountAnalyticLine(models.Model): unit_amount = fields.Float('Quantity', default=0.0) product_uom_id = fields.Many2one('uom.uom', string='Unit of Measure', domain="[('category_id', '=', product_uom_category_id)]") product_uom_category_id = fields.Many2one(related='product_uom_id.category_id', readonly=True) - account_id = fields.Many2one('account.analytic.account', 'Analytic Account', required=True, ondelete='restrict', index=True) - partner_id = fields.Many2one('res.partner', string='Partner') + account_id = fields.Many2one('account.analytic.account', 'Analytic Account', required=True, ondelete='restrict', index=True, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") + partner_id = fields.Many2one('res.partner', string='Partner', domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") user_id = fields.Many2one('res.users', string='User', default=_default_user) - tag_ids = fields.Many2many('account.analytic.tag', 'account_analytic_line_tag_rel', 'line_id', 'tag_id', string='Tags', copy=True) + tag_ids = fields.Many2many('account.analytic.tag', 'account_analytic_line_tag_rel', 'line_id', 'tag_id', string='Tags', copy=True, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") company_id = fields.Many2one('res.company', string='Company', required=True, readonly=True, default=lambda self: self.env.company) currency_id = fields.Many2one(related="company_id.currency_id", string="Currency", readonly=True, store=True, compute_sudo=True) group_id = fields.Many2one('account.analytic.group', related='account_id.group_id', store=True, readonly=True, compute_sudo=True) diff --git a/addons/crm/models/crm_lead.py b/addons/crm/models/crm_lead.py index bdd19fcf859..b35ac3a9468 100644 --- a/addons/crm/models/crm_lead.py +++ b/addons/crm/models/crm_lead.py @@ -73,7 +73,7 @@ class Lead(models.Model): name = fields.Char('Opportunity', required=True, index=True) partner_id = fields.Many2one('res.partner', string='Customer', tracking=10, index=True, - help="Linked partner (optional). Usually created when converting the lead. You can find a partner by its Name, TIN, Email or Internal Reference.") + domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", help="Linked partner (optional). Usually created when converting the lead. You can find a partner by its Name, TIN, Email or Internal Reference.") active = fields.Boolean('Active', default=True, tracking=True) date_action_last = fields.Datetime('Last Action', readonly=True) email_from = fields.Char('Email', help="Email address of the contact", tracking=40, index=True) diff --git a/addons/crm/views/crm_lead_views.xml b/addons/crm/views/crm_lead_views.xml index aad1c75f647..f2040741795 100644 --- a/addons/crm/views/crm_lead_views.xml +++ b/addons/crm/views/crm_lead_views.xml @@ -133,7 +133,7 @@ <group> <field name="user_id" domain="[('share', '=', False)]" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'sales_team.group_sale_salesman_all_leads'], 'team_id': team_id}"/> - <field name="team_id" widget="selection" domain="[('use_leads','=',True)]"/> + <field name="team_id" widget="selection" domain="[('use_leads','=',True),'|', ('company_id', '=', False), ('company_id', '=', company_id)]"/> <field name="type" invisible="1"/> </group> <group> @@ -624,11 +624,12 @@ <group> <field name="user_id" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'sales_team.group_sale_salesman_all_leads'], 'team_id': team_id}" domain="[('share', '=', False)]"/> - <field name="team_id" widget="selection" domain="[('use_opportunities', '=', True)]"/> + <field name="team_id" widget="selection" domain="[('use_opportunities', '=', True), '|', ('company_id', '=', False), ('company_id', '=', company_id)]"/> </group> <group> <field name="lost_reason" attrs="{'invisible': [('active', '=', True)]}"/> <field name="date_conversion" invisible="1"/> + <field name="company_id" groups="base.group_multi_company"/> </group> </group> diff --git a/addons/delivery/models/sale_order.py b/addons/delivery/models/sale_order.py index fa6401f54c7..879c3a356ec 100644 --- a/addons/delivery/models/sale_order.py +++ b/addons/delivery/models/sale_order.py @@ -8,7 +8,7 @@ from odoo.exceptions import UserError class SaleOrder(models.Model): _inherit = 'sale.order' - carrier_id = fields.Many2one('delivery.carrier', string="Delivery Method", help="Fill this field if you plan to invoice the shipping based on picking.") + carrier_id = fields.Many2one('delivery.carrier', string="Delivery Method", domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", help="Fill this field if you plan to invoice the shipping based on picking.") delivery_message = fields.Char(readonly=True, copy=False) delivery_rating_success = fields.Boolean(copy=False) delivery_set = fields.Boolean(compute='_compute_delivery_state') diff --git a/addons/delivery/wizard/choose_delivery_carrier.py b/addons/delivery/wizard/choose_delivery_carrier.py index c02fa5d30ca..960ec878a31 100644 --- a/addons/delivery/wizard/choose_delivery_carrier.py +++ b/addons/delivery/wizard/choose_delivery_carrier.py @@ -21,6 +21,7 @@ class ChooseDeliveryCarrier(models.TransientModel): delivery_price = fields.Float() display_price = fields.Float(string='Cost') currency_id = fields.Many2one('res.currency', related='order_id.currency_id') + company_id = fields.Many2one('res.company', related='order_id.company_id') available_carrier_ids = fields.Many2many("delivery.carrier", compute='_compute_available_carrier', string="Available Carriers") invoicing_message = fields.Text(compute='_compute_invoicing_message') delivery_message = fields.Text(readonly=True) diff --git a/addons/delivery/wizard/choose_delivery_carrier_views.xml b/addons/delivery/wizard/choose_delivery_carrier_views.xml index c0876733a1a..8cb84732659 100644 --- a/addons/delivery/wizard/choose_delivery_carrier_views.xml +++ b/addons/delivery/wizard/choose_delivery_carrier_views.xml @@ -8,9 +8,10 @@ <field name='available_carrier_ids' invisible="1"/> <group> <group> - <field name="carrier_id" domain="[('id', 'in', available_carrier_ids)]" widget='radio'/> + <field name="carrier_id" domain="[('id', 'in', available_carrier_ids), ('company_id', '=', company_id)]" widget='radio'/> <field name="delivery_type" invisible="1"/> <field name="currency_id" invisible="1"/> + <field name="company_id" invisible="1"/> <field name="order_id" invisible="1"/> <field name='delivery_price' invisible="1"/> <label for="display_price"/> diff --git a/addons/event/models/event.py b/addons/event/models/event.py index a416c610d93..bd7c5511fe3 100644 --- a/addons/event/models/event.py +++ b/addons/event/models/event.py @@ -108,7 +108,8 @@ class EventEvent(models.Model): organizer_id = fields.Many2one( 'res.partner', string='Organizer', tracking=True, - default=lambda self: self.env.company.partner_id) + default=lambda self: self.env.company.partner_id, + domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") event_type_id = fields.Many2one( 'event.type', string='Category', readonly=False, states={'done': [('readonly', True)]}) @@ -168,6 +169,7 @@ class EventEvent(models.Model): 'res.partner', string='Location', default=lambda self: self.env.company.partner_id, readonly=False, states={'done': [('readonly', True)]}, + domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", tracking=True) country_id = fields.Many2one('res.country', 'Country', related='address_id.country_id', store=True, readonly=False) twitter_hashtag = fields.Char('Twitter Hashtag') diff --git a/addons/event_sale/models/event.py b/addons/event_sale/models/event.py index 98485e5dd1d..0b9d5aa3513 100644 --- a/addons/event_sale/models/event.py +++ b/addons/event_sale/models/event.py @@ -71,6 +71,7 @@ class EventTicket(models.Model): name = fields.Char(string='Name', required=True, translate=True) event_type_id = fields.Many2one('event.type', string='Event Category', ondelete='cascade') event_id = fields.Many2one('event.event', string="Event", ondelete='cascade') + company_id = fields.Many2one('res.company', related='event_id.company_id') product_id = fields.Many2one('product.product', string='Product', required=True, domain=[("event_ok", "=", True)], default=_default_product_id) diff --git a/addons/event_sale/views/event_views.xml b/addons/event_sale/views/event_views.xml index f0e4462dea5..de162e3450d 100644 --- a/addons/event_sale/views/event_views.xml +++ b/addons/event_sale/views/event_views.xml @@ -6,7 +6,7 @@ <field name="inherit_id" ref="event.view_registration_search" /> <field name="arch" type="xml"> <filter name="group_event" position="after"> - <filter string="Ticket Type" name ="tickettype" domain="[]" context="{'group_by':'event_ticket_id'}"/> + <filter string="Ticket Type" name ="tickettype" domain="['|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]" context="{'group_by':'event_ticket_id'}"/> </filter> </field> </record> diff --git a/addons/event_sale/views/sale_order_views.xml b/addons/event_sale/views/sale_order_views.xml index 4af17bfbaa9..aca5b637696 100644 --- a/addons/event_sale/views/sale_order_views.xml +++ b/addons/event_sale/views/sale_order_views.xml @@ -10,7 +10,8 @@ name="event_id" domain="[ ('event_ticket_ids.product_id','=', product_id), - ('date_end','>=',time.strftime('%Y-%m-%d 00:00:00')) + ('date_end','>=',time.strftime('%Y-%m-%d 00:00:00')), + '|', ('company_id', '=', False), ('company_id', '=', parent.company_id) ]" attrs="{'invisible': [('event_ok', '=', False)], 'required': [('event_ok', '!=', False)]}" options="{'no_open': True, 'no_create': True}" @@ -20,7 +21,7 @@ domain="[ ('event_id', '=', event_id), ('product_id','=',product_id), - '|', ('seats_availability', '=', 'unlimited'), ('seats_available', '>', 0) + '|', ('seats_availability', '=', 'unlimited'), ('seats_available', '>', 0), '|', ('company_id', '=', False), ('company_id', '=', parent.company_id) ]" attrs="{ 'invisible': ['|', ('event_ok', '=', False), ('event_id', '=', False)], @@ -32,8 +33,8 @@ </xpath> <xpath expr="//field[@name='order_line']//tree//field[@name='product_template_id']" position="after"> <field name="event_ok" invisible="1" /> - <field name="event_id" optional="hide" /> - <field name="event_ticket_id" optional="hide" /> + <field name="event_id" optional="hide" domain="['|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]"/> + <field name="event_ticket_id" optional="hide" domain="['|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]"/> </xpath> </field> </record> diff --git a/addons/fleet/models/fleet_vehicle.py b/addons/fleet/models/fleet_vehicle.py index ce22e580d7c..982d2e4319a 100644 --- a/addons/fleet/models/fleet_vehicle.py +++ b/addons/fleet/models/fleet_vehicle.py @@ -25,7 +25,7 @@ class FleetVehicle(models.Model): help='License plate number of the vehicle (i = plate number for a car)') vin_sn = fields.Char('Chassis Number', help='Unique number written on the vehicle motor (VIN/SN number)', copy=False) driver_id = fields.Many2one('res.partner', 'Driver', tracking=True, help='Driver of the vehicle', copy=False) - future_driver_id = fields.Many2one('res.partner', 'Future Driver', tracking=True, help='Next Driver of the vehicle', copy=False) + future_driver_id = fields.Many2one('res.partner', 'Future Driver', tracking=True, help='Next Driver of the vehicle', copy=False, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") model_id = fields.Many2one('fleet.vehicle.model', 'Model', tracking=True, required=True, help='Model of the vehicle') manager_id = fields.Many2one('res.users', related='model_id.manager_id') diff --git a/addons/fleet/views/fleet_vehicle_views.xml b/addons/fleet/views/fleet_vehicle_views.xml index 5d138d607df..d0f175358d3 100644 --- a/addons/fleet/views/fleet_vehicle_views.xml +++ b/addons/fleet/views/fleet_vehicle_views.xml @@ -76,7 +76,7 @@ <group col="2"> <group string="Driver"> <field name="active" invisible="1"/> - <field name="driver_id"/> + <field name="driver_id" domain="['|', ('company_id', '=', False ), ('company_id', '=', company_id)]"/> <label for="future_driver_id"/> <div class="o_row"> <field name="future_driver_id"/> diff --git a/addons/hr/models/hr_department.py b/addons/hr/models/hr_department.py index d754117a408..f7008f25ef6 100644 --- a/addons/hr/models/hr_department.py +++ b/addons/hr/models/hr_department.py @@ -16,9 +16,9 @@ class Department(models.Model): complete_name = fields.Char('Complete Name', compute='_compute_complete_name', store=True) active = fields.Boolean('Active', default=True) company_id = fields.Many2one('res.company', string='Company', index=True, default=lambda self: self.env.company) - parent_id = fields.Many2one('hr.department', string='Parent Department', index=True) + parent_id = fields.Many2one('hr.department', string='Parent Department', index=True, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") child_ids = fields.One2many('hr.department', 'parent_id', string='Child Departments') - manager_id = fields.Many2one('hr.employee', string='Manager', tracking=True) + manager_id = fields.Many2one('hr.employee', string='Manager', tracking=True, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") member_ids = fields.One2many('hr.employee', 'department_id', string='Members', readonly=True) jobs_ids = fields.One2many('hr.job', 'department_id', string='Jobs') note = fields.Text('Note') diff --git a/addons/hr/models/hr_employee.py b/addons/hr/models/hr_employee.py index df264e75078..9835d737aee 100644 --- a/addons/hr/models/hr_employee.py +++ b/addons/hr/models/hr_employee.py @@ -42,7 +42,8 @@ class HrEmployeePrivate(models.Model): # private partner address_home_id = fields.Many2one( 'res.partner', 'Address', help='Enter here the private address of the employee, not the one linked to your company.', - groups="hr.group_hr_user", tracking=True) + groups="hr.group_hr_user", tracking=True, + domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") is_address_home_a_company = fields.Boolean( 'The employee address has a company linked', compute='_compute_is_address_home_a_company', @@ -74,7 +75,7 @@ class HrEmployeePrivate(models.Model): passport_id = fields.Char('Passport No', groups="hr.group_hr_user", tracking=True) bank_account_id = fields.Many2one( 'res.partner.bank', 'Bank Account Number', - domain="[('partner_id', '=', address_home_id)]", + domain="[('partner_id', '=', address_home_id), '|', ('company_id', '=', False), ('company_id', '=', company_id)]", groups="hr.group_hr_user", tracking=True, help='Employee bank salary account') @@ -96,9 +97,9 @@ class HrEmployeePrivate(models.Model): image_1920 = fields.Image(default=_default_image) phone = fields.Char(related='address_home_id.phone', related_sudo=False, string="Private Phone", groups="hr.group_hr_user") # employee in company - parent_id = fields.Many2one('hr.employee', 'Manager') + parent_id = fields.Many2one('hr.employee', 'Manager', domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") child_ids = fields.One2many('hr.employee', 'parent_id', string='Direct subordinates') - coach_id = fields.Many2one('hr.employee', 'Coach') + coach_id = fields.Many2one('hr.employee', 'Coach', domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") category_ids = fields.Many2many( 'hr.employee.category', 'employee_category_rel', 'emp_id', 'category_id', groups="hr.group_hr_manager", diff --git a/addons/hr/models/hr_employee_base.py b/addons/hr/models/hr_employee_base.py index 20e1ff374fe..b8b94ad51ed 100644 --- a/addons/hr/models/hr_employee_base.py +++ b/addons/hr/models/hr_employee_base.py @@ -12,18 +12,18 @@ class HrEmployeeBase(models.AbstractModel): name = fields.Char() active = fields.Boolean("Active") color = fields.Integer('Color Index', default=0) - department_id = fields.Many2one('hr.department', 'Department') - job_id = fields.Many2one('hr.job', 'Job Position') + department_id = fields.Many2one('hr.department', 'Department', domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") + job_id = fields.Many2one('hr.job', 'Job Position', domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") job_title = fields.Char("Job Title") company_id = fields.Many2one('res.company', 'Company') - address_id = fields.Many2one('res.partner', 'Work Address') + address_id = fields.Many2one('res.partner', 'Work Address', domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") work_phone = fields.Char('Work Phone') mobile_phone = fields.Char('Work Mobile') work_email = fields.Char('Work Email') work_location = fields.Char('Work Location') user_id = fields.Many2one('res.users') resource_id = fields.Many2one('resource.resource') - resource_calendar_id = fields.Many2one('resource.calendar') + resource_calendar_id = fields.Many2one('resource.calendar', domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") hr_presence_state = fields.Selection([ ('present', 'Present'), ('absent', 'Absent'), diff --git a/addons/hr/models/hr_job.py b/addons/hr/models/hr_job.py index a10b9fd86b6..51271f4170d 100644 --- a/addons/hr/models/hr_job.py +++ b/addons/hr/models/hr_job.py @@ -22,7 +22,7 @@ class Job(models.Model): employee_ids = fields.One2many('hr.employee', 'job_id', string='Employees', groups='base.group_user') description = fields.Text(string='Job Description') requirements = fields.Text('Requirements') - department_id = fields.Many2one('hr.department', string='Department') + department_id = fields.Many2one('hr.department', string='Department', domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") company_id = fields.Many2one('res.company', string='Company', default=lambda self: self.env.company) state = fields.Selection([ ('recruit', 'Recruitment in Progress'), diff --git a/addons/hr/views/hr_employee_views.xml b/addons/hr/views/hr_employee_views.xml index cea424933b4..7a088421ae3 100644 --- a/addons/hr/views/hr_employee_views.xml +++ b/addons/hr/views/hr_employee_views.xml @@ -88,12 +88,12 @@ <field name="mobile_phone" widget="phone"/> <field name="work_phone" widget="phone"/> <field name="work_email" widget="email"/> + <field name="company_id" groups="base.group_multi_company"/> </group> <group> <field name="department_id"/> <field name="job_id"/> <field name="parent_id"/> - <field name="company_id" groups="base.group_multi_company"/> </group> </group> <notebook> diff --git a/addons/hr_contract/models/hr_contract.py b/addons/hr_contract/models/hr_contract.py index 64aec5ea1b8..62c053fefd9 100644 --- a/addons/hr_contract/models/hr_contract.py +++ b/addons/hr_contract/models/hr_contract.py @@ -16,9 +16,9 @@ class Contract(models.Model): name = fields.Char('Contract Reference', required=True) active = fields.Boolean(default=True) - employee_id = fields.Many2one('hr.employee', string='Employee', tracking=True) - department_id = fields.Many2one('hr.department', string="Department") - job_id = fields.Many2one('hr.job', string='Job Position') + employee_id = fields.Many2one('hr.employee', string='Employee', tracking=True, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") + department_id = fields.Many2one('hr.department', domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", string="Department") + job_id = fields.Many2one('hr.job', domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", string='Job Position') date_start = fields.Date('Start Date', required=True, default=fields.Date.today, help="Start date of the contract.") date_end = fields.Date('End Date', @@ -27,7 +27,8 @@ class Contract(models.Model): help="End date of the trial period (if there is one).") resource_calendar_id = fields.Many2one( 'resource.calendar', 'Working Schedule', - default=lambda self: self.env.company.resource_calendar_id.id) + default=lambda self: self.env.company.resource_calendar_id.id, + domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") wage = fields.Monetary('Wage', required=True, tracking=True, help="Employee's monthly gross wage.") advantages = fields.Text('Advantages') notes = fields.Text('Notes') @@ -38,7 +39,7 @@ class Contract(models.Model): ('cancel', 'Cancelled') ], string='Status', group_expand='_expand_states', tracking=True, help='Status of the contract', default='draft') - company_id = fields.Many2one('res.company', default=lambda self: self.env.company) + company_id = fields.Many2one('res.company', default=lambda self: self.env.company, required=True) """ kanban_state: * draft + green = "Incoming" state (will be set as Open once the contract has started) diff --git a/addons/hr_contract/models/hr_employee.py b/addons/hr_contract/models/hr_employee.py index a1f36d333b7..917b68d5054 100644 --- a/addons/hr_contract/models/hr_employee.py +++ b/addons/hr_contract/models/hr_employee.py @@ -12,7 +12,7 @@ class Employee(models.Model): vehicle = fields.Char(string='Company Vehicle', groups="hr.group_hr_user") contract_ids = fields.One2many('hr.contract', 'employee_id', string='Employee Contracts') contract_id = fields.Many2one('hr.contract', string='Current Contract', - groups="hr.group_hr_user", help='Current contract of the employee') + groups="hr.group_hr_user",domain="[('company_id', '=', company_id)]", help='Current contract of the employee') calendar_mismatch = fields.Boolean(related='contract_id.calendar_mismatch') contracts_count = fields.Integer(compute='_compute_contracts_count', string='Contract Count') contract_warning = fields.Boolean(string='Contract Warning', store=True, compute='_compute_contract_warning', groups="hr.group_hr_user") diff --git a/addons/hr_contract/views/hr_contract_views.xml b/addons/hr_contract/views/hr_contract_views.xml index c42daf47a3a..d6cb731b628 100644 --- a/addons/hr_contract/views/hr_contract_views.xml +++ b/addons/hr_contract/views/hr_contract_views.xml @@ -151,6 +151,7 @@ </group> <group> <field name="job_id"/> + <field name="company_id" invisible="1"/> </group> </group> <notebook> diff --git a/addons/hr_expense/models/hr_expense.py b/addons/hr_expense/models/hr_expense.py index b1b198a1390..83ed84cbc52 100644 --- a/addons/hr_expense/models/hr_expense.py +++ b/addons/hr_expense/models/hr_expense.py @@ -30,37 +30,38 @@ class HrExpense(models.Model): @api.model def _get_employee_id_domain(self): - res= [('id', '=', 0)] # Nothing accepted by domain, by default + res = "[('id', '=', 0), '|', ('company_id', '=', False), ('company_id', '=', company_id)]" # Nothing accepted by domain, by default if self.user_has_groups('hr_expense.group_hr_expense_user') or self.user_has_groups('account.group_account_user'): - res = [] # Then, domain accepts everything + res = "['|', ('company_id', '=', False), ('company_id', '=', company_id)]" # Then, domain accepts everything elif self.user_has_groups('hr_expense.group_hr_expense_team_approver') and self.env.user.employee_ids: employee = self.env.user.employee_ids[0] res = ['|', '|', '|', ('department_id.manager_id.id', '=', employee.id), - ('parent_id.id', '=', employee.id), ('expense_manager_id.id', '=', employee.user_id.id), ('id', '=', employee.id)] + ('parent_id.id', '=', employee.id), ('expense_manager_id.id', '=', employee.user_id.id), ('id', '=', employee.id), + '|', ('company_id', '=', False), ('company_id', '=', employee.company_id.id)] elif self.env.user.employee_ids: employee = self.env.user.employee_ids[0] - res = [('id', '=', employee.id)] + res = [('id', '=', employee.id), '|', ('company_id', '=', False), ('company_id', '=', employee.company_id.id)] return res name = fields.Char('Description', readonly=True, required=True, states={'draft': [('readonly', False)], 'reported': [('readonly', False)], 'refused': [('readonly', False)]}) date = fields.Date(readonly=True, states={'draft': [('readonly', False)], 'reported': [('readonly', False)], 'refused': [('readonly', False)]}, default=fields.Date.context_today, string="Date") employee_id = fields.Many2one('hr.employee', string="Employee", required=True, readonly=True, states={'draft': [('readonly', False)], 'reported': [('readonly', False)], 'refused': [('readonly', False)]}, default=_default_employee_id, domain=lambda self: self._get_employee_id_domain()) # product_id not required to allow create an expense without product via mail alias, but should be required on the view. - product_id = fields.Many2one('product.product', string='Product', readonly=True, states={'draft': [('readonly', False)], 'reported': [('readonly', False)], 'refused': [('readonly', False)]}, domain=[('can_be_expensed', '=', True)]) + product_id = fields.Many2one('product.product', string='Product', readonly=True, states={'draft': [('readonly', False)], 'reported': [('readonly', False)], 'refused': [('readonly', False)]}, domain="[('can_be_expensed', '=', True), '|', ('company_id', '=', False), ('company_id', '=', company_id)]") product_uom_id = fields.Many2one('uom.uom', string='Unit of Measure', readonly=True, states={'draft': [('readonly', False)], 'refused': [('readonly', False)]}, default=_default_product_uom_id, domain="[('category_id', '=', product_uom_category_id)]") product_uom_category_id = fields.Many2one(related='product_id.uom_id.category_id', readonly=True) unit_amount = fields.Float("Unit Price", readonly=True, required=True, states={'draft': [('readonly', False)], 'reported': [('readonly', False)], 'refused': [('readonly', False)]}, digits='Product Price') quantity = fields.Float(required=True, readonly=True, states={'draft': [('readonly', False)], 'reported': [('readonly', False)], 'refused': [('readonly', False)]}, digits='Product Unit of Measure', default=1) - tax_ids = fields.Many2many('account.tax', 'expense_tax', 'expense_id', 'tax_id', string='Taxes') + tax_ids = fields.Many2many('account.tax', 'expense_tax', 'expense_id', 'tax_id', domain="[('company_id', '=', company_id)]", string='Taxes') untaxed_amount = fields.Float("Subtotal", store=True, compute='_compute_amount', digits='Account') total_amount = fields.Monetary("Total", compute='_compute_amount', store=True, currency_field='currency_id') company_currency_id = fields.Many2one('res.currency', string="Report Company Currency", related='sheet_id.currency_id', store=True, readonly=False) total_amount_company = fields.Monetary("Total (Company Currency)", compute='_compute_total_amount_company', store=True, currency_field='company_currency_id') company_id = fields.Many2one('res.company', string='Company', readonly=True, states={'draft': [('readonly', False)], 'refused': [('readonly', False)]}, default=lambda self: self.env.company) currency_id = fields.Many2one('res.currency', string='Currency', readonly=True, states={'draft': [('readonly', False)], 'refused': [('readonly', False)]}, default=lambda self: self.env.company.currency_id) - analytic_account_id = fields.Many2one('account.analytic.account', string='Analytic Account') - analytic_tag_ids = fields.Many2many('account.analytic.tag', string='Analytic Tags', states={'post': [('readonly', True)], 'done': [('readonly', True)]}) - account_id = fields.Many2one('account.account', string='Account', default=_default_account_id, help="An expense account is expected") + analytic_account_id = fields.Many2one('account.analytic.account', string='Analytic Account', domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") + analytic_tag_ids = fields.Many2many('account.analytic.tag', string='Analytic Tags', states={'post': [('readonly', True)], 'done': [('readonly', True)]}, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") + account_id = fields.Many2one('account.account', domain="[('company_id', '=', company_id)]", string='Account', default=_default_account_id, help="An expense account is expected") description = fields.Text('Notes...', readonly=True, states={'draft': [('readonly', False)], 'reported': [('readonly', False)], 'refused': [('readonly', False)]}) payment_mode = fields.Selection([ ("own_account", "Employee (to reimburse)"), @@ -614,16 +615,16 @@ class HrExpenseSheet(models.Model): ('done', 'Paid'), ('cancel', 'Refused') ], string='Status', index=True, readonly=True, tracking=True, copy=False, default='draft', required=True, help='Expense Report State') - employee_id = fields.Many2one('hr.employee', string="Employee", required=True, readonly=True, states={'draft': [('readonly', False)]}, default=lambda self: self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)) - address_id = fields.Many2one('res.partner', string="Employee Home Address") + employee_id = fields.Many2one('hr.employee', string="Employee", required=True, readonly=True, states={'draft': [('readonly', False)]}, default=lambda self: self.env['hr.employee'].search([('user_id', '=', self.env.uid)], domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", limit=1)) + address_id = fields.Many2one('res.partner', domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", string="Employee Home Address") payment_mode = fields.Selection(related='expense_line_ids.payment_mode', default='own_account', readonly=True, string="Paid By") user_id = fields.Many2one('res.users', 'Manager', readonly=True, copy=False, states={'draft': [('readonly', False)]}, tracking=True) total_amount = fields.Monetary('Total Amount', currency_field='currency_id', compute='_compute_amount', store=True) company_id = fields.Many2one('res.company', string='Company', readonly=True, states={'draft': [('readonly', False)]}, default=lambda self: self.env.company) currency_id = fields.Many2one('res.currency', string='Currency', readonly=True, states={'draft': [('readonly', False)]}, default=lambda self: self.env.company.currency_id) attachment_number = fields.Integer(compute='_compute_attachment_number', string='Number of Attachments') - journal_id = fields.Many2one('account.journal', string='Expense Journal', states={'done': [('readonly', True)], 'post': [('readonly', True)]}, default=_default_journal_id, help="The journal used when the expense is done.") - bank_journal_id = fields.Many2one('account.journal', string='Bank Journal', states={'done': [('readonly', True)], 'post': [('readonly', True)]}, default=_default_bank_journal_id, help="The payment method used when the expense is paid by the company.") + journal_id = fields.Many2one('account.journal', string='Expense Journal', states={'done': [('readonly', True)], 'post': [('readonly', True)]}, default=_default_journal_id, domain="[('company_id', '=', company_id)]", help="The journal used when the expense is done.") + bank_journal_id = fields.Many2one('account.journal', string='Bank Journal', states={'done': [('readonly', True)], 'post': [('readonly', True)]}, default=_default_bank_journal_id, domain="[('company_id', '=', company_id)]", help="The payment method used when the expense is paid by the company.") accounting_date = fields.Date("Date") account_move_id = fields.Many2one('account.move', string='Journal Entry', ondelete='restrict', copy=False) department_id = fields.Many2one('hr.department', string='Department', states={'post': [('readonly', True)], 'done': [('readonly', True)]}) diff --git a/addons/hr_expense/views/hr_expense_views.xml b/addons/hr_expense/views/hr_expense_views.xml index 87c6182e73e..6958e26f4a4 100644 --- a/addons/hr_expense/views/hr_expense_views.xml +++ b/addons/hr_expense/views/hr_expense_views.xml @@ -93,7 +93,7 @@ </group><group> <field name="reference" attrs="{'readonly': [('is_ref_editable', '=', False)]}"/> <field name="date"/> - <field name="account_id" options="{'no_create': True}" domain="[('internal_type', '=', 'other')]" groups="account.group_account_user" attrs="{'readonly': [('is_editable', '=', False)]}"/> + <field name="account_id" options="{'no_create': True}" domain="[('internal_type', '=', 'other'), ('company_id', '=', company_id)]" groups="account.group_account_user" attrs="{'readonly': [('is_editable', '=', False)]}"/> <field name="employee_id" groups="hr_expense.group_hr_expense_team_approver"/> <field name="sheet_id" invisible="1"/> <field name="currency_id" groups="base.group_multi_currency"/> diff --git a/addons/hr_expense/wizard/hr_expense_sheet_register_payment.py b/addons/hr_expense/wizard/hr_expense_sheet_register_payment.py index f8fbe16ab22..b6a312307ba 100644 --- a/addons/hr_expense/wizard/hr_expense_sheet_register_payment.py +++ b/addons/hr_expense/wizard/hr_expense_sheet_register_payment.py @@ -17,9 +17,9 @@ class HrExpenseSheetRegisterPaymentWizard(models.TransientModel): expense_sheet = self.env['hr.expense.sheet'].browse(active_ids) return expense_sheet.address_id.id or expense_sheet.employee_id.id and expense_sheet.employee_id.address_home_id.id - partner_id = fields.Many2one('res.partner', string='Partner', required=True, default=_default_partner_id) - partner_bank_account_id = fields.Many2one('res.partner.bank', string="Recipient Bank Account") - journal_id = fields.Many2one('account.journal', string='Payment Method', required=True, domain=[('type', 'in', ('bank', 'cash'))]) + partner_id = fields.Many2one('res.partner', string='Partner', required=True, default=_default_partner_id, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") + partner_bank_account_id = fields.Many2one('res.partner.bank', string="Recipient Bank Account", domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") + journal_id = fields.Many2one('account.journal', string='Payment Method', required=True, domain="[('type', 'in', ('bank', 'cash')), ('company_id', '=', company_id)]") company_id = fields.Many2one('res.company', related='journal_id.company_id', string='Company', readonly=True, required=True) payment_method_id = fields.Many2one('account.payment.method', string='Payment Type', required=True) amount = fields.Monetary(string='Payment Amount', required=True) diff --git a/addons/hr_expense/wizard/hr_expense_sheet_register_payment.xml b/addons/hr_expense/wizard/hr_expense_sheet_register_payment.xml index df376a52d2f..d5bb87cbce4 100644 --- a/addons/hr_expense/wizard/hr_expense_sheet_register_payment.xml +++ b/addons/hr_expense/wizard/hr_expense_sheet_register_payment.xml @@ -28,6 +28,7 @@ <group> <field name="payment_date"/> <field name="communication"/> + <field name="company_id" invisible="1"/> </group> </group> </sheet> diff --git a/addons/hr_recruitment/models/hr_job.py b/addons/hr_recruitment/models/hr_job.py index 00f19f64e58..7fb74433099 100644 --- a/addons/hr_recruitment/models/hr_job.py +++ b/addons/hr_recruitment/models/hr_job.py @@ -17,6 +17,7 @@ class Job(models.Model): address_id = fields.Many2one( 'res.partner', "Job Location", default=_default_address_id, + domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", help="Address where employees are working") application_ids = fields.One2many('hr.applicant', 'job_id', "Applications") application_count = fields.Integer(compute='_compute_application_count', string="Application Count") diff --git a/addons/hr_recruitment/models/hr_recruitment.py b/addons/hr_recruitment/models/hr_recruitment.py index 97d41598526..f42fd24b9b9 100644 --- a/addons/hr_recruitment/models/hr_recruitment.py +++ b/addons/hr_recruitment/models/hr_recruitment.py @@ -133,7 +133,7 @@ class Applicant(models.Model): date_open = fields.Datetime("Assigned", readonly=True, index=True) date_last_stage_update = fields.Datetime("Last Stage Update", index=True, default=fields.Datetime.now) priority = fields.Selection(AVAILABLE_PRIORITIES, "Appreciation", default='0') - job_id = fields.Many2one('hr.job', "Applied Job") + job_id = fields.Many2one('hr.job', "Applied Job", domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") salary_proposed_extra = fields.Char("Proposed Salary Extra", help="Salary Proposed by the Organisation, extra advantages") salary_expected_extra = fields.Char("Expected Salary Extra", help="Salary Expected by Applicant, extra advantages") salary_proposed = fields.Float("Proposed Salary", group_operator="avg", help="Salary Proposed by the Organisation") @@ -143,7 +143,7 @@ class Applicant(models.Model): partner_phone = fields.Char("Phone", size=32) partner_mobile = fields.Char("Mobile", size=32) type_id = fields.Many2one('hr.recruitment.degree', "Degree") - department_id = fields.Many2one('hr.department', "Department") + department_id = fields.Many2one('hr.department', "Department", domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") day_open = fields.Float(compute='_compute_day', string="Days to Open") day_close = fields.Float(compute='_compute_day', string="Days to Close") delay_close = fields.Float(compute="_compute_day", string='Delay to Close', readonly=True, group_operator="avg", help="Number of days to close", store=True) diff --git a/addons/hr_recruitment/views/hr_recruitment_views.xml b/addons/hr_recruitment/views/hr_recruitment_views.xml index 4ba41d79687..4d69afc9a8a 100644 --- a/addons/hr_recruitment/views/hr_recruitment_views.xml +++ b/addons/hr_recruitment/views/hr_recruitment_views.xml @@ -261,6 +261,7 @@ <field name="partner_name"/> <field name="email_from"/> <field name="job_id" options="{'no_open': True}"/> + <field name="company_id" invisible="1"/> </group> </form> </field> diff --git a/addons/hr_timesheet/models/hr_timesheet.py b/addons/hr_timesheet/models/hr_timesheet.py index 1e13fd00d4d..84354c64f7a 100644 --- a/addons/hr_timesheet/models/hr_timesheet.py +++ b/addons/hr_timesheet/models/hr_timesheet.py @@ -20,7 +20,7 @@ class AccountAnalyticLine(models.Model): result['employee_id'] = self.env['hr.employee'].search([('user_id', '=', result['user_id'])], limit=1).id return result - task_id = fields.Many2one('project.task', 'Task', index=True) + task_id = fields.Many2one('project.task', 'Task', index=True, domain="[('company_id', '=', company_id)]") project_id = fields.Many2one('project.project', 'Project', domain=[('allow_timesheets', '=', True)]) employee_id = fields.Many2one('hr.employee', "Employee") diff --git a/addons/hr_work_entry/models/hr_work_entry.py b/addons/hr_work_entry/models/hr_work_entry.py index 845c353f552..fcf3b2e7174 100644 --- a/addons/hr_work_entry/models/hr_work_entry.py +++ b/addons/hr_work_entry/models/hr_work_entry.py @@ -14,7 +14,7 @@ class HrWorkEntry(models.Model): name = fields.Char(required=True) active = fields.Boolean(default=True) - employee_id = fields.Many2one('hr.employee', required=True) + employee_id = fields.Many2one('hr.employee', required=True, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") date_start = fields.Datetime(required=True, string='From') date_stop = fields.Datetime(string='To') duration = fields.Float(compute='_compute_duration', inverse='_inverse_duration', store=True, string="Period") diff --git a/addons/hr_work_entry/views/hr_work_entry_views.xml b/addons/hr_work_entry/views/hr_work_entry_views.xml index bfcca473186..1071b2d8205 100644 --- a/addons/hr_work_entry/views/hr_work_entry_views.xml +++ b/addons/hr_work_entry/views/hr_work_entry_views.xml @@ -60,6 +60,7 @@ <div> <field name="duration" nolabel="1" attrs="{'readonly': [('state', '!=', 'draft')]}" /><span class="ml8">Hours</span> </div> + <field name="company_id" invisible="1"/> </group> </group> </sheet> diff --git a/addons/l10n_in_sale/models/sale_order.py b/addons/l10n_in_sale/models/sale_order.py index e6493a1c296..0dd61a784a3 100644 --- a/addons/l10n_in_sale/models/sale_order.py +++ b/addons/l10n_in_sale/models/sale_order.py @@ -8,7 +8,7 @@ class SaleOrder(models.Model): _inherit = "sale.order" l10n_in_reseller_partner_id = fields.Many2one('res.partner', - string='Reseller', domain=[('vat', '!=', False)], states={'posted': [('readonly', True)]}) + string='Reseller', domain="[('vat', '!=', False), '|', ('company_id', '=', False), ('company_id', '=', company_id)]", states={'posted': [('readonly', True)]}) def _prepare_invoice(self): invoice_vals = super(SaleOrder, self)._prepare_invoice() diff --git a/addons/payment/models/payment_acquirer.py b/addons/payment/models/payment_acquirer.py index f33db57faf8..31df0df1cd8 100644 --- a/addons/payment/models/payment_acquirer.py +++ b/addons/payment/models/payment_acquirer.py @@ -104,7 +104,7 @@ class PaymentAcquirer(models.Model): capture_manually = fields.Boolean(string="Capture Amount Manually", help="Capture the amount from Odoo, when the delivery is completed.") journal_id = fields.Many2one( - 'account.journal', 'Payment Journal', domain=[('type', 'in', ['bank', 'cash'])], + 'account.journal', 'Payment Journal', domain="[('type', 'in', ['bank', 'cash']), ('company_id', '=', company_id)]", help="""Journal where the successful transactions will be posted""") check_validity = fields.Boolean(string="Verify Card Validity", help="""Trigger a transaction of 1 currency unit and its refund to check the validity of new credit cards entered in the customer portal. diff --git a/addons/project/models/project.py b/addons/project/models/project.py index 86c513695fd..11f1c838d50 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -164,10 +164,11 @@ class Project(models.Model): active = fields.Boolean(default=True, help="If the active field is set to False, it will allow you to hide the project without removing it.") sequence = fields.Integer(default=10, help="Gives the sequence order when displaying a list of Projects.") - partner_id = fields.Many2one('res.partner', string='Customer', auto_join=True, tracking=True) + partner_id = fields.Many2one('res.partner', string='Customer', auto_join=True, tracking=True, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") company_id = fields.Many2one('res.company', string='Company', required=True, default=lambda self: self.env.company) currency_id = fields.Many2one('res.currency', related="company_id.currency_id", string="Currency", readonly=True) analytic_account_id = fields.Many2one('account.analytic.account', string="Analytic Account", copy=False, ondelete='set null', + domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", help="Analytic account to which this project is linked for financial management. " "Use an analytic account to record cost and revenue on your project.") @@ -182,6 +183,7 @@ class Project(models.Model): resource_calendar_id = fields.Many2one( 'resource.calendar', string='Working Time', default=lambda self: self.env.company.resource_calendar_id.id, + domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", help="Timetable working hours to adjust the gantt diagram report") type_ids = fields.Many2many('project.task.type', 'project_task_type_rel', 'project_id', 'type_id', string='Tasks Stages') task_count = fields.Integer(compute='_compute_task_count', string="Task Count") @@ -209,6 +211,7 @@ class Project(models.Model): date_start = fields.Date(string='Start Date') date = fields.Date(string='Expiration Date', index=True, tracking=True) subtask_project_id = fields.Many2one('project.project', string='Sub-task Project', ondelete="restrict", + domain="[('company_id', '=', company_id)]", help="Project in which sub-tasks of the current project will be created. It can be the current project itself.") # rating fields @@ -502,7 +505,8 @@ class Task(models.Model): index=True, tracking=True) partner_id = fields.Many2one('res.partner', string='Customer', - default=lambda self: self._get_default_partner()) + default=lambda self: self._get_default_partner(), + domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") manager_id = fields.Many2one('res.users', string='Project Manager', related='project_id.user_id', readonly=True, related_sudo=False) company_id = fields.Many2one('res.company', string='Company', required=True, default=lambda self: self.env.company) color = fields.Integer(string='Color Index') diff --git a/addons/project/views/project_views.xml b/addons/project/views/project_views.xml index e1d90113f56..56850cce140 100644 --- a/addons/project/views/project_views.xml +++ b/addons/project/views/project_views.xml @@ -453,7 +453,7 @@ </div> <group> <group> - <field name="project_id" domain="[('active', '=', True)]" options="{'no_create': True}"/> + <field name="project_id" domain="[('active', '=', True), ('company_id', '=', company_id)]" options="{'no_create': True}"/> <field name="active" invisible="1"/> <field name="user_id" class="o_task_user_field" diff --git a/addons/project_timesheet_holidays/models/hr_holidays.py b/addons/project_timesheet_holidays/models/hr_holidays.py index b8b78758c2b..fc4c60b9a89 100644 --- a/addons/project_timesheet_holidays/models/hr_holidays.py +++ b/addons/project_timesheet_holidays/models/hr_holidays.py @@ -17,8 +17,8 @@ class HolidaysType(models.Model): return company.leave_timesheet_task_id.id timesheet_generate = fields.Boolean('Generate Timesheet', default=True, help="If checked, when validating a time off, timesheet will be generated in the Vacation Project of the company.") - timesheet_project_id = fields.Many2one('project.project', string="Project", default=_default_project_id, help="The project will contain the timesheet generated when a time off is validated.") - timesheet_task_id = fields.Many2one('project.task', string="Task for timesheet", default=_default_task_id, domain="[('project_id', '=', timesheet_project_id)]") + timesheet_project_id = fields.Many2one('project.project', string="Project", default=_default_project_id, domain="[('company_id', '=', company_id)]", help="The project will contain the timesheet generated when a time off is validated.") + timesheet_task_id = fields.Many2one('project.task', string="Task for timesheet", default=_default_task_id, domain="[('project_id', '=', timesheet_project_id), ('company_id', '=', company_id)]") @api.onchange('timesheet_task_id') def _onchange_timesheet_generate(self): diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index 816f093eaff..c4969d12add 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -71,8 +71,8 @@ class PurchaseOrder(models.Model): date_order = fields.Datetime('Order Date', required=True, states=READONLY_STATES, index=True, copy=False, default=fields.Datetime.now,\ help="Depicts the date where the Quotation should be validated and converted into a purchase order.") date_approve = fields.Datetime('Confirmation Date', readonly=1, index=True, copy=False) - partner_id = fields.Many2one('res.partner', string='Vendor', required=True, states=READONLY_STATES, change_default=True, tracking=True, help="You can find a vendor by its Name, TIN, Email or Internal Reference.") - dest_address_id = fields.Many2one('res.partner', string='Drop Ship Address', states=READONLY_STATES, + partner_id = fields.Many2one('res.partner', string='Vendor', required=True, states=READONLY_STATES, change_default=True, tracking=True, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", help="You can find a vendor by its Name, TIN, Email or Internal Reference.") + dest_address_id = fields.Many2one('res.partner', domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", string='Drop Ship Address', states=READONLY_STATES, help="Put an address if you want to deliver directly from the vendor to the customer. " "Otherwise, keep empty to deliver to your own company.") currency_id = fields.Many2one('res.currency', 'Currency', required=True, states=READONLY_STATES, @@ -103,8 +103,8 @@ class PurchaseOrder(models.Model): amount_tax = fields.Monetary(string='Taxes', store=True, readonly=True, compute='_amount_all') amount_total = fields.Monetary(string='Total', store=True, readonly=True, compute='_amount_all') - fiscal_position_id = fields.Many2one('account.fiscal.position', string='Fiscal Position') - payment_term_id = fields.Many2one('account.payment.term', 'Payment Terms') + fiscal_position_id = fields.Many2one('account.fiscal.position', string='Fiscal Position', domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") + payment_term_id = fields.Many2one('account.payment.term', 'Payment Terms', domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") incoterm_id = fields.Many2one('account.incoterms', 'Incoterm', states={'done': [('readonly', True)]}, help="International Commercial Terms are a series of predefined commercial terms used in international transactions.") product_id = fields.Many2one('product.product', related='order_line.product_id', string='Product', readonly=False) diff --git a/addons/purchase/views/purchase_views.xml b/addons/purchase/views/purchase_views.xml index 85f009c0fff..4fd68ace317 100644 --- a/addons/purchase/views/purchase_views.xml +++ b/addons/purchase/views/purchase_views.xml @@ -197,9 +197,8 @@ force_save="1" domain="[('purchase_ok', '=', True), '|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]"/> <field name="name" widget="section_and_note_text"/> <field name="date_planned" optional="hide" attrs="{'required': [('display_type', '=', False)], 'readonly': [('parent.date_planned', '!=', False)]}"/> - <field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/> - <field name="account_analytic_id" optional="hide" context="{'default_partner_id':parent.partner_id}" groups="analytic.group_analytic_accounting"/> - <field name="analytic_tag_ids" optional="hide" groups="analytic.group_analytic_tags" widget="many2many_tags" options="{'color_field': 'color'}"/> + <field name="account_analytic_id" optional="hide" context="{'default_partner_id':parent.partner_id}" groups="analytic.group_analytic_accounting" domain="['|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]"/> + <field name="analytic_tag_ids" optional="hide" groups="analytic.group_analytic_tags" widget="many2many_tags" options="{'color_field': 'color'}" domain="['|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]"/> <field name="product_qty"/> <field name="qty_received_manual" invisible="1"/> <field name="qty_received_method" invisible="1"/> @@ -212,7 +211,7 @@ }" force_save="1" optional="show"/> <field name="price_unit"/> - <field name="taxes_id" widget="many2many_tags" domain="[('type_tax_use','=','purchase')]" context="{'default_type_tax_use': 'purchase', 'search_view_ref': 'account.account_tax_view_search'}" options="{'no_create': True}" optional="show"/> + <field name="taxes_id" widget="many2many_tags" domain="[('type_tax_use','=','purchase'), ('company_id', '=', parent.company_id)]" context="{'default_type_tax_use': 'purchase', 'search_view_ref': 'account.account_tax_view_search'}" options="{'no_create': True}" optional="show"/> <field name="price_subtotal" widget="monetary"/> </tree> <form string="Purchase Order Line"> @@ -235,12 +234,12 @@ <field name="qty_received" string="Received Quantity" attrs="{'invisible': [('parent.state', 'not in', ('purchase', 'done'))], 'readonly': [('qty_received_method', '!=', 'manual')]}"/> <field name="qty_invoiced" string="Billed Quantity" attrs="{'invisible': [('parent.state', 'not in', ('purchase', 'done'))]}"/> <field name="price_unit"/> - <field name="taxes_id" widget="many2many_tags" domain="[('type_tax_use', '=', 'purchase')]" options="{'no_create': True}"/> + <field name="taxes_id" widget="many2many_tags" domain="[('type_tax_use', '=', 'purchase'), ('company_id', '=', parent.company_id)]" options="{'no_create': True}"/> </group> <group> <field name="date_planned" widget="date" attrs="{'required': [('display_type', '=', False)]}"/> - <field name="account_analytic_id" colspan="2" groups="analytic.group_analytic_accounting"/> - <field name="analytic_tag_ids" groups="analytic.group_analytic_accounting" widget="many2many_tags" options="{'color_field': 'color'}"/> + <field name="account_analytic_id" colspan="2" domain="['|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]" groups="analytic.group_analytic_accounting"/> + <field name="analytic_tag_ids" groups="analytic.group_analytic_accounting" domain="['|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]" widget="many2many_tags" options="{'color_field': 'color'}"/> <field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/> </group> <group colspan="12"> diff --git a/addons/purchase_requisition/models/purchase_requisition.py b/addons/purchase_requisition/models/purchase_requisition.py index ed6a793f7e6..c150385114e 100644 --- a/addons/purchase_requisition/models/purchase_requisition.py +++ b/addons/purchase_requisition/models/purchase_requisition.py @@ -48,7 +48,7 @@ class PurchaseRequisition(models.Model): name = fields.Char(string='Agreement Reference', required=True, copy=False, default='New', readonly=True) origin = fields.Char(string='Source Document') order_count = fields.Integer(compute='_compute_orders_number', string='Number of Orders') - vendor_id = fields.Many2one('res.partner', string="Vendor") + vendor_id = fields.Many2one('res.partner', string="Vendor", domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") type_id = fields.Many2one('purchase.requisition.type', string="Agreement Type", required=True, default=_get_type_id) ordering_date = fields.Date(string="Ordering Date", tracking=True) date_end = fields.Datetime(string='Agreement Deadline', tracking=True) diff --git a/addons/purchase_requisition/views/purchase_requisition_views.xml b/addons/purchase_requisition/views/purchase_requisition_views.xml index 93042504bc8..792a2f5ca00 100644 --- a/addons/purchase_requisition/views/purchase_requisition_views.xml +++ b/addons/purchase_requisition/views/purchase_requisition_views.xml @@ -163,14 +163,14 @@ <page string="Products"> <field name="line_ids"> <tree string="Products" editable="bottom"> - <field name="product_id" context="{'default_purchase_requisition': 'tenders'}"/> + <field name="product_id" context="{'default_purchase_requisition': 'tenders'}" domain="['|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]"/> <field name="product_qty"/> <field name="qty_ordered" optional="show"/> <field name="product_uom_category_id" invisible="1"/> <field name="product_uom_id" string="UoM" groups="uom.group_uom" optional="show"/> <field name="schedule_date" groups="base.group_no_one"/> - <field name="account_analytic_id" optional="hide" groups="analytic.group_analytic_accounting"/> - <field name="analytic_tag_ids" optional="hide" groups="analytic.group_analytic_tags" widget="many2many_tags"/> + <field name="account_analytic_id" optional="hide" domain="['|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]" groups="analytic.group_analytic_accounting"/> + <field name="analytic_tag_ids" optional="hide" domain="['|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]" groups="analytic.group_analytic_tags" widget="many2many_tags"/> <field name="price_unit"/> </tree> <form string="Products"> @@ -181,7 +181,7 @@ <field name="product_uom_category_id" invisible="1"/> <field name="product_uom_id" /> <field name="schedule_date"/> - <field name="account_analytic_id" groups="analytic.group_analytic_accounting"/> + <field name="account_analytic_id" domain="['|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]" groups="analytic.group_analytic_accounting"/> <field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/> </group> </form> diff --git a/addons/purchase_requisition/views/purchase_views.xml b/addons/purchase_requisition/views/purchase_views.xml index 1a0c99b6f8c..224d7c52420 100644 --- a/addons/purchase_requisition/views/purchase_views.xml +++ b/addons/purchase_requisition/views/purchase_views.xml @@ -11,7 +11,7 @@ <field name="partner_id" context="{'res_partner_search_mode': 'supplier'}" attrs="{'readonly': ['|', ('is_quantity_copy', '=', 'none'), ('state', 'in', ['purchase', 'done', 'cancel'])]}" force_save="1"/> </field> <field name="partner_ref" position="after"> - <field name="requisition_id" domain="[('state', 'in', ('in_progress', 'open', 'ongoing')), ('vendor_id', 'in', (partner_id, False))]"/> + <field name="requisition_id" domain="[('state', 'in', ('in_progress', 'open', 'ongoing')), ('vendor_id', 'in', (partner_id, False)), ('company_id', '=', company_id)]"/> </field> </field> </record> diff --git a/addons/purchase_requisition_stock/models/purchase_requisition.py b/addons/purchase_requisition_stock/models/purchase_requisition.py index aa85cd1e295..3614b16fb7d 100644 --- a/addons/purchase_requisition_stock/models/purchase_requisition.py +++ b/addons/purchase_requisition_stock/models/purchase_requisition.py @@ -17,8 +17,8 @@ class PurchaseRequisition(models.Model): ) return pick_in - warehouse_id = fields.Many2one('stock.warehouse', string='Warehouse') - picking_type_id = fields.Many2one('stock.picking.type', 'Operation Type', required=True, default=_get_picking_in) + warehouse_id = fields.Many2one('stock.warehouse', string='Warehouse', domain="[('company_id', '=', company_id)]") + picking_type_id = fields.Many2one('stock.picking.type', 'Operation Type', required=True, default=_get_picking_in, domain="['|',('warehouse_id', '=', False), ('warehouse_id.company_id', '=', company_id)]") def _prepare_tender_values(self, product_id, product_qty, product_uom, location_id, name, origin, company_id, values): res = super(PurchaseRequisition, self)._prepare_tender_values(product_id, product_qty, product_uom, location_id, name, origin, company_id, values) diff --git a/addons/purchase_stock/models/purchase.py b/addons/purchase_stock/models/purchase.py index 7837c3984d7..7d408aa908f 100644 --- a/addons/purchase_stock/models/purchase.py +++ b/addons/purchase_stock/models/purchase.py @@ -26,7 +26,7 @@ class PurchaseOrder(models.Model): picking_count = fields.Integer(compute='_compute_picking', string='Picking count', default=0, store=True) picking_ids = fields.Many2many('stock.picking', compute='_compute_picking', string='Receptions', copy=False, store=True) - picking_type_id = fields.Many2one('stock.picking.type', 'Deliver To', states=Purchase.READONLY_STATES, required=True, default=_default_picking_type, + picking_type_id = fields.Many2one('stock.picking.type', 'Deliver To', states=Purchase.READONLY_STATES, required=True, default=_default_picking_type, domain="['|', ('warehouse_id', '=', False), ('warehouse_id.company_id', '=', company_id)]", help="This will determine operation type of incoming shipment") default_location_dest_id_usage = fields.Selection(related='picking_type_id.default_location_dest_id.usage', string='Destination Location Type', help="Technical field used to display the Drop Ship Address", readonly=True) diff --git a/addons/purchase_stock/views/purchase_views.xml b/addons/purchase_stock/views/purchase_views.xml index 947ba72b686..f42a82c73f2 100644 --- a/addons/purchase_stock/views/purchase_views.xml +++ b/addons/purchase_stock/views/purchase_views.xml @@ -34,7 +34,7 @@ <attribute name="attrs">{'column_invisible': [('parent.state', 'not in', ('purchase', 'done'))], 'readonly': [('product_type', 'in', ('consu', 'product'))]}</attribute> </xpath> <xpath expr="//page[@name='purchase_delivery_invoice']/group/group" position="inside"> - <field name="picking_type_id" domain="[('code','=','incoming')]" options="{'no_create': True}" groups="stock.group_stock_multi_locations"/> + <field name="picking_type_id" domain="[('code','=','incoming'), '|', ('warehouse_id', '=', False), ('warehouse_id.company_id', '=', company_id)]" options="{'no_create': True}" groups="stock.group_stock_multi_locations"/> <field name="dest_address_id" groups="stock.group_stock_multi_locations" attrs="{'invisible': [('default_location_dest_id_usage', '!=', 'customer')], 'required': [('default_location_dest_id_usage', '=', 'customer')]}"/> <field name="default_location_dest_id_usage" invisible="1"/> <field name="incoterm_id"/> diff --git a/addons/sale/models/account_invoice.py b/addons/sale/models/account_invoice.py index 0dc4a1be605..6f24f05b06b 100644 --- a/addons/sale/models/account_invoice.py +++ b/addons/sale/models/account_invoice.py @@ -12,12 +12,13 @@ class AccountMove(models.Model): def _get_invoice_default_sale_team(self): return self.env['crm.team']._get_default_team_id() - team_id = fields.Many2one('crm.team', string='Sales Team', default=_get_invoice_default_sale_team) + team_id = fields.Many2one('crm.team', string='Sales Team', default=_get_invoice_default_sale_team, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") partner_shipping_id = fields.Many2one( 'res.partner', string='Delivery Address', readonly=True, states={'draft': [('readonly', False)]}, + domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", help="Delivery address for current invoice.") @api.onchange('partner_shipping_id') diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index 1a3f75914c4..a6cc73b6c93 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -143,13 +143,13 @@ class SaleOrder(models.Model): remaining_validity_days = fields.Integer(compute='_compute_remaining_validity_days', string="Remaining Days Before Expiration") create_date = fields.Datetime(string='Creation Date', readonly=True, index=True, help="Date on which sales order is created.") user_id = fields.Many2one('res.users', string='Salesperson', index=True, tracking=2, default=lambda self: self.env.user) - partner_id = fields.Many2one('res.partner', string='Customer', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, required=True, change_default=True, index=True, tracking=1, help="You can find a customer from their name, email, tax ID or reference.") - partner_invoice_id = fields.Many2one('res.partner', string='Invoice Address', readonly=True, required=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)], 'sale': [('readonly', False)]}, help="Invoice address for current sales order.") - partner_shipping_id = fields.Many2one('res.partner', string='Delivery Address', readonly=True, required=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)], 'sale': [('readonly', False)]}, help="Delivery address for current sales order.") + partner_id = fields.Many2one('res.partner', string='Customer', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, required=True, change_default=True, index=True, tracking=1, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", help="You can find a customer from their name, email, tax ID or reference.") + partner_invoice_id = fields.Many2one('res.partner', string='Invoice Address', readonly=True, required=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)], 'sale': [('readonly', False)]}, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", help="Invoice address for current sales order.") + partner_shipping_id = fields.Many2one('res.partner', string='Delivery Address', readonly=True, required=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)], 'sale': [('readonly', False)]}, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", help="Delivery address for current sales order.") - pricelist_id = fields.Many2one('product.pricelist', string='Pricelist', required=True, readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help="Pricelist for current order. If you change the pricelist, only new lines will consider this pricelist.") + pricelist_id = fields.Many2one('product.pricelist', string='Pricelist', required=True, readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", help="Pricelist for current order. If you change the pricelist, only new lines will consider this pricelist.") currency_id = fields.Many2one("res.currency", related='pricelist_id.currency_id', string="Currency", readonly=True, required=True) - analytic_account_id = fields.Many2one('account.analytic.account', 'Analytic Account', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help="The analytic account related to a sales order.", copy=False) + analytic_account_id = fields.Many2one('account.analytic.account', 'Analytic Account', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", help="The analytic account related to a sales order.", copy=False) order_line = fields.One2many('sale.order.line', 'order_id', string='Order Lines', states={'cancel': [('readonly', True)], 'done': [('readonly', True)]}, copy=True, auto_join=True) @@ -170,10 +170,10 @@ class SaleOrder(models.Model): amount_total = fields.Monetary(string='Total', store=True, readonly=True, compute='_amount_all', tracking=4) currency_rate = fields.Float("Currency Rate", compute='_compute_currency_rate', compute_sudo=True, store=True, digits=(12, 6), readonly=True, help='The rate of the currency to the currency of rate 1 applicable at the date of the order') - payment_term_id = fields.Many2one('account.payment.term', string='Payment Terms', help="Payment terms applies to all invoices issued from this order.") - fiscal_position_id = fields.Many2one('account.fiscal.position', string='Fiscal Position', help=" Fiscal positions are used to adapt taxes and accounts for particular customers or sales orders/invoices. The default value comes from the customer.") + payment_term_id = fields.Many2one('account.payment.term', string='Payment Terms', domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", help="Payment terms applies to all invoices issued from this order.") + fiscal_position_id = fields.Many2one('account.fiscal.position', string='Fiscal Position', domain="[('company_id', '=', company_id)]", help=" Fiscal positions are used to adapt taxes and accounts for particular customers or sales orders/invoices. The default value comes from the customer.") company_id = fields.Many2one('res.company', 'Company', required=True, default=lambda self: self.env.company) - team_id = fields.Many2one('crm.team', 'Sales Team', change_default=True, default=_get_default_team) + team_id = fields.Many2one('crm.team', 'Sales Team', change_default=True, default=_get_default_team, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") signature = fields.Binary('Signature', help='Signature received through the portal.', copy=False, attachment=True) signed_by = fields.Char('Signed By', help='Name of the person that signed the SO.', copy=False) diff --git a/addons/sale/views/sale_views.xml b/addons/sale/views/sale_views.xml index cfe127a9442..f2e74fee747 100644 --- a/addons/sale/views/sale_views.xml +++ b/addons/sale/views/sale_views.xml @@ -393,7 +393,7 @@ <div name="lead"> <field name="customer_lead" class="oe_inline"/> days </div> - <field name="analytic_tag_ids" widget="many2many_tags" groups="analytic.group_analytic_tags" options="{'color_field': 'color'}"/> + <field name="analytic_tag_ids" widget="many2many_tags" groups="analytic.group_analytic_tags" options="{'color_field': 'color'}" domain="['|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]"/> </group> </group> <label for="name" string="Description" attrs="{'invisible': [('display_type', '!=', False)]}"/> @@ -469,6 +469,7 @@ groups="analytic.group_analytic_tags" widget="many2many_tags" options="{'color_field': 'color'}" + domain="['|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]" /> <field name="product_uom_qty" diff --git a/addons/sale_crm/models/sale_order.py b/addons/sale_crm/models/sale_order.py index e635f2fe81b..80696686e3e 100644 --- a/addons/sale_crm/models/sale_order.py +++ b/addons/sale_crm/models/sale_order.py @@ -8,4 +8,4 @@ class SaleOrder(models.Model): _inherit = 'sale.order' tag_ids = fields.Many2many('crm.lead.tag', 'sale_order_tag_rel', 'order_id', 'tag_id', string='Tags') - opportunity_id = fields.Many2one('crm.lead', string='Opportunity', domain="[('type', '=', 'opportunity')]") + opportunity_id = fields.Many2one('crm.lead', string='Opportunity', domain="[('type', '=', 'opportunity'), '|', ('company_id', '=', False), ('company_id', '=', company_id)]") diff --git a/addons/sale_expense/models/hr_expense.py b/addons/sale_expense/models/hr_expense.py index 1ab41e299ad..a7a2c983b55 100644 --- a/addons/sale_expense/models/hr_expense.py +++ b/addons/sale_expense/models/hr_expense.py @@ -7,7 +7,7 @@ from odoo import api, fields, models class Expense(models.Model): _inherit = "hr.expense" - sale_order_id = fields.Many2one('sale.order', string='Sale Order', readonly=True, states={'draft': [('readonly', False)], 'reported': [('readonly', False)]}, domain=[('state', '=', 'sale')]) + sale_order_id = fields.Many2one('sale.order', string='Sale Order', readonly=True, states={'draft': [('readonly', False)], 'reported': [('readonly', False)]}, domain="[('state', '=', 'sale'), ('company_id', '=', company_id)]") @api.onchange('sale_order_id') def _onchange_sale_order(self): diff --git a/addons/sale_stock/models/sale_order.py b/addons/sale_stock/models/sale_order.py index 20cf2f40a87..3de03891dc2 100644 --- a/addons/sale_stock/models/sale_order.py +++ b/addons/sale_stock/models/sale_order.py @@ -31,7 +31,7 @@ class SaleOrder(models.Model): warehouse_id = fields.Many2one( 'stock.warehouse', string='Warehouse', required=True, readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, - default=_default_warehouse_id) + default=_default_warehouse_id, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") picking_ids = fields.One2many('stock.picking', 'sale_id', string='Transfers') delivery_count = fields.Integer(string='Delivery Orders', compute='_compute_picking_ids') procurement_group_id = fields.Many2one('procurement.group', 'Procurement Group', copy=False) diff --git a/addons/sale_timesheet/models/project.py b/addons/sale_timesheet/models/project.py index 63d1d451e43..17c80bf21b2 100644 --- a/addons/sale_timesheet/models/project.py +++ b/addons/sale_timesheet/models/project.py @@ -8,7 +8,7 @@ from odoo.exceptions import ValidationError class Project(models.Model): _inherit = 'project.project' - sale_line_id = fields.Many2one('sale.order.line', 'Sales Order Item', domain="[('is_expense', '=', False), ('order_id', '=', sale_order_id), ('state', 'in', ['sale', 'done'])]", copy=False, + sale_line_id = fields.Many2one('sale.order.line', 'Sales Order Item', domain="[('is_expense', '=', False), ('order_id', '=', sale_order_id), ('state', 'in', ['sale', 'done']), '|', ('company_id', '=', False), ('company_id', '=', company_id)]", copy=False, help="Sales order item to which the project is linked. If an employee timesheets on a task that does not have a " "sale order item defines, and if this employee is not in the 'Employee/Sales Order Item Mapping' of the project, " "the timesheet entry will be linked to the sales order item defined on the project.") @@ -143,7 +143,7 @@ class ProjectTask(models.Model): sale_line_id = project.sale_line_id.id return sale_line_id - sale_line_id = fields.Many2one('sale.order.line', 'Sales Order Item', default=_default_sale_line_id, domain="[('is_service', '=', True), ('order_partner_id', '=', partner_id), ('is_expense', '=', False), ('state', 'in', ['sale', 'done'])]", + sale_line_id = fields.Many2one('sale.order.line', 'Sales Order Item', default=_default_sale_line_id, domain="[('is_service', '=', True), ('order_partner_id', '=', partner_id), ('is_expense', '=', False), ('state', 'in', ['sale', 'done']), '|', ('company_id', '=', False), ('company_id', '=', company_id)]", help="Sales order item to which the task is linked. If an employee timesheets on a this task, " "and if this employee is not in the 'Employee/Sales Order Item Mapping' of the project, the " "timesheet entry will be linked to this sales order item.") diff --git a/addons/sale_timesheet/models/sale_order.py b/addons/sale_timesheet/models/sale_order.py index d3de544a857..2d7e6ab9bcf 100644 --- a/addons/sale_timesheet/models/sale_order.py +++ b/addons/sale_timesheet/models/sale_order.py @@ -19,7 +19,7 @@ class SaleOrder(models.Model): visible_project = fields.Boolean('Display project', compute='_compute_visible_project', readonly=True) project_id = fields.Many2one( - 'project.project', 'Project', domain=[('billable_type', 'in', ('no', 'task_rate')), ('analytic_account_id', '!=', False)], + 'project.project', 'Project', domain="[('billable_type', 'in', ('no', 'task_rate')), ('analytic_account_id', '!=', False), ('company_id', '=', company_id)]", readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help='Select a non billable project on which tasks can be created.') project_ids = fields.Many2many('project.project', compute="_compute_project_ids", string='Projects', copy=False, groups="project.group_project_user", help="Projects used in this sales order.") diff --git a/addons/stock/views/stock_move_views.xml b/addons/stock/views/stock_move_views.xml index cea99857eb5..fde8c1a3793 100644 --- a/addons/stock/views/stock_move_views.xml +++ b/addons/stock/views/stock_move_views.xml @@ -461,7 +461,7 @@ <field name="model">stock.move</field> <field name="priority" eval="6"/> <field name="arch" type="xml"> - <tree decoration-muted="state == 'cancel'" default_order='date_expected, picking_id, sequence' string="Moves"> + <tree decoration-muted="state == 'cancel'" default_order='date_expected, picking_id, sequence' string="Moves" create="0"> <field name="date_expected" widget='date'/> <field name="date" string="Creation date" widget="date" optional="hide"/> <field name="picking_id" string="Reference" invisible="1"/> diff --git a/addons/website_crm_partner_assign/models/crm_lead.py b/addons/website_crm_partner_assign/models/crm_lead.py index 3ad8feca747..b3c5eb86325 100644 --- a/addons/website_crm_partner_assign/models/crm_lead.py +++ b/addons/website_crm_partner_assign/models/crm_lead.py @@ -11,7 +11,7 @@ class CrmLead(models.Model): _inherit = "crm.lead" partner_latitude = fields.Float('Geo Latitude', digits=(16, 5)) partner_longitude = fields.Float('Geo Longitude', digits=(16, 5)) - partner_assigned_id = fields.Many2one('res.partner', 'Assigned Partner', tracking=True, help="Partner this case has been forwarded/assigned to.", index=True) + partner_assigned_id = fields.Many2one('res.partner', 'Assigned Partner', tracking=True, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", help="Partner this case has been forwarded/assigned to.", index=True) partner_declined_ids = fields.Many2many( 'res.partner', 'crm_lead_declined_partner', diff --git a/addons/website_event/views/event_views.xml b/addons/website_event/views/event_views.xml index 59fa3d2837f..46aa80e2dc8 100644 --- a/addons/website_event/views/event_views.xml +++ b/addons/website_event/views/event_views.xml @@ -31,7 +31,7 @@ <field name="inherit_id" ref="event.view_event_form"/> <field name="arch" type="xml"> <field name="organizer_id" position="before"> - <field name="website_id" options="{'no_create': True}" groups="website.group_multi_website"/> + <field name="website_id" options="{'no_create': True}" domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]" groups="website.group_multi_website"/> </field> <div name="button_box" position="inside"> <field name="website_url" invisible="1"/> @@ -61,7 +61,7 @@ <field name="inherit_id" ref="event.view_event_tree"/> <field name="arch" type="xml"> <field name="name" position="after"> - <field name="website_id" groups="website.group_multi_website"/> + <field name="website_id" groups="website.group_multi_website" domain="['|', ('company_id', '=', company_id), ('company_id', '=', False)]"/> </field> </field> </record> diff --git a/addons/website_event_track/models/event_track.py b/addons/website_event_track/models/event_track.py index bc6318b6faa..7fc23534864 100644 --- a/addons/website_event_track/models/event_track.py +++ b/addons/website_event_track/models/event_track.py @@ -58,6 +58,7 @@ class Track(models.Model): name = fields.Char('Title', required=True, translate=True) active = fields.Boolean(default=True) user_id = fields.Many2one('res.users', 'Responsible', tracking=True, default=lambda self: self.env.user) + company_id = fields.Many2one('res.company', related='event_id.company_id') partner_id = fields.Many2one('res.partner', 'Partner') partner_name = fields.Char('Name') partner_email = fields.Char('Email') diff --git a/addons/website_event_track/views/event_track_views.xml b/addons/website_event_track/views/event_track_views.xml index 4bfd4898957..e74e4fd446e 100644 --- a/addons/website_event_track/views/event_track_views.xml +++ b/addons/website_event_track/views/event_track_views.xml @@ -137,7 +137,9 @@ <field name="active" invisible="1"/> </group> <group> + <field name="company_id" invisible="1"/> <field name="user_id"/> + <field name="partner_id" domain="['|', ('company_id', '=', company_id), ('company_id', '=', False)]"/> <field name="event_id"/> <field name="tag_ids" widget="many2many_tags" options="{'color_field': 'color'}"/> </group> diff --git a/addons/website_hr_recruitment/views/hr_recruitment_views.xml b/addons/website_hr_recruitment/views/hr_recruitment_views.xml index 931cab4d458..03a4176db6b 100644 --- a/addons/website_hr_recruitment/views/hr_recruitment_views.xml +++ b/addons/website_hr_recruitment/views/hr_recruitment_views.xml @@ -28,7 +28,7 @@ <field name="inherit_id" ref="hr.view_hr_job_form"/> <field name="arch" type="xml"> <field name="company_id" position="after"> - <field name="website_id" options="{'no_create': True}" groups="website.group_multi_website"/> + <field name="website_id" options="{'no_create': True}" domain="['|', ('company_id', '=', company_id), ('company_id', '=', False)]" groups="website.group_multi_website"/> </field> </field> </record> diff --git a/addons/website_payment/models/payment_acquirer.py b/addons/website_payment/models/payment_acquirer.py index fe0c00f9a26..6702aad9115 100644 --- a/addons/website_payment/models/payment_acquirer.py +++ b/addons/website_payment/models/payment_acquirer.py @@ -6,4 +6,4 @@ from odoo import fields, models class PaymentAcquirer(models.Model): _inherit = 'payment.acquirer' - website_id = fields.Many2one('website') + website_id = fields.Many2one('website', domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") |
