Skip to content

Commit

Permalink
[IMP] account_multicompany_ux: document type when company is changed.
Browse files Browse the repository at this point in the history
Task: 37459
If the company of a vendor bill is changed, then the document type is not changed.
Also post a message in the invoice with the company change

closes #145

X-original-commit: b347e54
Signed-off-by: Juan José Scarafía <jjs@adhoc.com.ar>
  • Loading branch information
pablohmontenegro committed Mar 11, 2024
1 parent dea41fa commit fa4d774
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion account_multicompany_ux/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
'name': 'Account Multicompany Usability',
'version': "16.0.1.1.0",
'version': "16.0.1.2.0",
'author': 'ADHOC SA',
'website': 'www.adhoc.com.ar',
'license': 'AGPL-3',
Expand Down
1 change: 1 addition & 0 deletions account_multicompany_ux/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class AccountMove(models.Model):
_inherit = 'account.move'

reversed_entry_id = fields.Many2one(check_company=False)
company_id = fields.Many2one(tracking=True)

@api.constrains('company_id')
def check_company(self):
Expand Down
10 changes: 8 additions & 2 deletions account_multicompany_ux/wizards/account_change_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ def change_company(self):
if self.move_id._fields.get('l10n_latam_manual_document_number') and self.move_id.l10n_latam_manual_document_number and self.move_id.name:
old_name = self.move_id.name
self.move_id.name = '/'
old_doc_type = False
if self.move_id._fields.get('l10n_latam_document_type_id') and self.move_id.l10n_latam_manual_document_number:
old_doc_type = self.move_id.l10n_latam_document_type_id

self.move_id.write({
'company_id': self.company_id.id,
'journal_id': self.journal_id.id,
Expand All @@ -74,5 +78,7 @@ def change_company(self):
self.move_id.invoice_line_ids.with_company(self.company_id.id)._compute_tax_ids()
for invoice_line in self.move_id.invoice_line_ids.filtered(lambda x: not x.product_id).with_company(self.company_id.id):
invoice_line.tax_ids = invoice_line._get_computed_taxes()
if old_name and self.move_id.l10n_latam_manual_document_number:
self.move_id.name = old_name
if old_doc_type and old_doc_type in self.move_id.l10n_latam_available_document_type_ids:
self.move_id.l10n_latam_document_type_id = old_doc_type
if self.move_id.l10n_latam_manual_document_number:
self.move_id.name = old_name

0 comments on commit fa4d774

Please sign in to comment.