Skip to content

Commit

Permalink
Merge PR #392 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by dreispt
  • Loading branch information
OCA-git-bot committed Nov 28, 2023
2 parents 54ac8a8 + 1e973ac commit 0d9998b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
27 changes: 14 additions & 13 deletions account_avatax_oca/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,20 +405,21 @@ def write(self, vals):
record.avatax_compute_taxes()
return result

@api.model
def create(self, vals):
record = super(AccountMove, self).create(vals)
@api.model_create_multi
def create(self, vals_list):
moves = super().create(vals_list)
avatax_config = self.env.company.get_avatax_config_company()
if (
avatax_config.invoice_calculate_tax
and record.calculate_tax_on_save
and not self._context.get("skip_second_write", False)
):
record.with_context(skip_second_write=True).write(
{"calculate_tax_on_save": False}
)
record.avatax_compute_taxes()
return record
for move in moves:
if (
avatax_config.invoice_calculate_tax
and move.calculate_tax_on_save
and not self._context.get("skip_second_write", False)
):
move.with_context(skip_second_write=True).write(
{"calculate_tax_on_save": False}
)
move.avatax_compute_taxes()
return moves


class AccountMoveLine(models.Model):
Expand Down
23 changes: 12 additions & 11 deletions account_avatax_oca/models/partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,18 +186,19 @@ def button_avatax_validate_address(self):
"context": ctx,
}

@api.model
def create(self, vals):
partner = super(ResPartner, self).create(vals)
# Auto populate customer code, if not provided
if not partner.customer_code:
partner.generate_cust_code()
# Auto validate address, if enabled
@api.model_create_multi
def create(self, vals_list):
partners = super().create(vals_list)
avatax_config = self.env.company.get_avatax_config_company()
if avatax_config.validation_on_save:
partner.multi_address_validation(validation_on_save=True)
partner.validated_on_save = True
return partner
for partner in partners:
# Auto populate customer code, if not provided
if not partner.customer_code:
partner.generate_cust_code()
# Auto validate address, if enabled
if avatax_config.validation_on_save:
partner.multi_address_validation(validation_on_save=True)
partner.validated_on_save = True
return partners

def write(self, vals):
res = super(ResPartner, self).write(vals)
Expand Down

0 comments on commit 0d9998b

Please sign in to comment.