diff --git a/sale_order_type/models/sale.py b/sale_order_type/models/sale.py index 25c32c2c3bb..c7c45821ea6 100644 --- a/sale_order_type/models/sale.py +++ b/sale_order_type/models/sale.py @@ -36,7 +36,7 @@ def _default_type_id(self): def _default_sequence_id(self): """We get the sequence in same way the core next_by_code method does so we can get the proper default sequence""" - force_company = self.company_id.id or self.env.company.id + force_company = self.env.company.id return self.env["ir.sequence"].search( [ ("code", "=", "sale.order"), @@ -116,7 +116,6 @@ def create(self, vals_list): def write(self, vals): """A sale type could have a different order sequence, so we could need to change it accordingly""" - default_sequence = self._default_sequence_id() if vals.get("type_id"): sale_type = self.env["sale.order.type"].browse(vals["type_id"]) if sale_type.sequence_id: @@ -126,7 +125,8 @@ def write(self, vals): # sequence has the same default sequence. ignore_default_sequence = ( not record.type_id.sequence_id - and sale_type.sequence_id == default_sequence + and sale_type.sequence_id + == record.with_company(record.company_id)._default_sequence_id() ) if ( record.state in {"draft", "sent"}