diff --git a/addons/account/__init__.py b/addons/account/__init__.py
index 866c39de02e..86d81923e02 100644
--- a/addons/account/__init__.py
+++ b/addons/account/__init__.py
@@ -45,6 +45,8 @@ def _auto_install_l10n(cr, registry):
'PL', 'PT', 'RO', 'SI', 'TR', 'UK', 'VE', 'VN'
]:
module_list.append('base_vat')
+ if country_code == 'MX':
+ module_list.append('l10n_mx_edi')
# European countries will be using SEPA
europe = env.ref('base.europe', raise_if_not_found=False)
diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py
index f2a5e0d785b..8d45a4518c2 100644
--- a/addons/account/models/account_invoice.py
+++ b/addons/account/models/account_invoice.py
@@ -70,6 +70,12 @@ class AccountInvoice(models.Model):
self.amount_total_signed = self.amount_total * sign
self.amount_untaxed_signed = amount_untaxed_signed * sign
+ def _compute_sign_taxes(self):
+ for invoice in self:
+ sign = invoice.type in ['in_refund', 'out_refund'] and -1 or 1
+ invoice.amount_untaxed_invoice_signed = invoice.amount_untaxed * sign
+ invoice.amount_tax_signed = invoice.amount_tax * sign
+
@api.onchange('amount_total')
def _onchange_amount_total(self):
for inv in self:
@@ -347,8 +353,12 @@ class AccountInvoice(models.Model):
store=True, readonly=True, compute='_compute_amount', tracking=True)
amount_untaxed_signed = fields.Monetary(string='Untaxed Amount in Company Currency', currency_field='company_currency_id',
store=True, readonly=True, compute='_compute_amount')
+ amount_untaxed_invoice_signed = fields.Monetary(string='Untaxed Amount in Invoice Currency', currency_field='currency_id',
+ readonly=True, compute='_compute_sign_taxes')
amount_tax = fields.Monetary(string='Tax',
store=True, readonly=True, compute='_compute_amount')
+ amount_tax_signed = fields.Monetary(string='Tax in Invoice Currency', currency_field='currency_id',
+ readonly=True, compute='_compute_sign_taxes')
amount_total = fields.Monetary(string='Total',
store=True, readonly=True, compute='_compute_amount')
amount_total_signed = fields.Monetary(string='Total in Invoice Currency', currency_field='currency_id',
@@ -785,7 +795,7 @@ class AccountInvoice(models.Model):
# Subscribe internal users on the newly created bill
partners = self.env['res.partner'].browse(seen_partner_ids)
is_internal = lambda p: (p.user_ids and
- all(p.user_ids.mapped(lambda u: u.user_has_groups('base.group_user'))))
+ all(p.user_ids.mapped(lambda u: u.has_group('base.group_user'))))
partners_to_subscribe = partners.filtered(is_internal)
if partners_to_subscribe:
invoice.message_subscribe([p.id for p in partners_to_subscribe])
@@ -1840,14 +1850,14 @@ class AccountInvoiceLine(models.Model):
def _set_taxes(self):
""" Used in on_change to set taxes and price"""
self.ensure_one()
- if self.invoice_id.type in ('out_invoice', 'out_refund'):
- taxes = self.product_id.taxes_id or self.account_id.tax_ids or self.invoice_id.company_id.account_sale_tax_id
- else:
- taxes = self.product_id.supplier_taxes_id or self.account_id.tax_ids or self.invoice_id.company_id.account_purchase_tax_id
# Keep only taxes of the company
company_id = self.company_id or self.env.user.company_id
- taxes = taxes.filtered(lambda r: r.company_id == company_id)
+
+ if self.invoice_id.type in ('out_invoice', 'out_refund'):
+ taxes = self.product_id.taxes_id.filtered(lambda r: r.company_id == company_id) or self.account_id.tax_ids or self.invoice_id.company_id.account_sale_tax_id
+ else:
+ taxes = self.product_id.supplier_taxes_id.filtered(lambda r: r.company_id == company_id) or self.account_id.tax_ids or self.invoice_id.company_id.account_purchase_tax_id
self.invoice_line_tax_ids = fp_taxes = self.invoice_id.fiscal_position_id.map_tax(taxes, self.product_id, self.invoice_id.partner_id)
diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py
index a32bdb0b818..40526a35e70 100644
--- a/addons/account/models/account_move.py
+++ b/addons/account/models/account_move.py
@@ -1060,7 +1060,7 @@ class AccountMoveLine(models.Model):
partner_id = self.env['res.partner']._find_accounting_partner(self[0].partner_id).id
company_currency = self[0].account_id.company_id.currency_id
- writeoff_currency = self[0].currency_id or company_currency
+ writeoff_currency = self[0].account_id.currency_id or company_currency
line_to_reconcile = self.env['account.move.line']
# Iterate and create one writeoff by journal
writeoff_moves = self.env['account.move']
diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py
index baca985def8..405abd5c3ce 100644
--- a/addons/account/models/account_payment.py
+++ b/addons/account/models/account_payment.py
@@ -108,6 +108,16 @@ class account_payment(models.Model):
# Check all invoices are open
if any(invoice.state != 'open' for invoice in invoices):
raise UserError(_("You can only register payments for open invoices"))
+ # Check if, in batch payments, there are not negative invoices and positive invoices
+ dtype = invoices[0].type
+ for inv in invoices[1:]:
+ if inv.type != dtype:
+ if ((dtype == 'in_refund' and inv.type == 'in_invoice') or
+ (dtype == 'in_invoice' and inv.type == 'in_refund')):
+ raise UserError(_("You cannot register payments for vendor bills and supplier refunds at the same time."))
+ if ((dtype == 'out_refund' and inv.type == 'out_invoice') or
+ (dtype == 'out_invoice' and inv.type == 'out_refund')):
+ raise UserError(_("You cannot register payments for customer invoices and credit notes at the same time."))
amount = self._compute_payment_amount(invoices, invoices[0].currency_id)
rec.update({
@@ -660,6 +670,20 @@ class account_payment(models.Model):
return vals
+ def _get_invoice_payment_amount(self, inv):
+ """
+ Computes the amount covered by the current payment in the given invoice.
+
+ :param inv: an invoice object
+ :returns: the amount covered by the payment in the invoice
+ """
+ self.ensure_one()
+ return sum([
+ data['amount']
+ for data in inv._get_payments_vals()
+ if data['account_payment_id'] == self.id
+ ])
+
class payment_register(models.TransientModel):
_name = 'account.payment.register'
diff --git a/addons/account/models/res_users.py b/addons/account/models/res_users.py
index ab85e359d22..8030423e74d 100644
--- a/addons/account/models/res_users.py
+++ b/addons/account/models/res_users.py
@@ -14,8 +14,8 @@ class Users(models.Model):
super(Users, self)._check_one_user_type()
users_with_both_groups = self.filtered(lambda user:
- user.user_has_groups('account.group_show_line_subtotals_tax_included') and
- user.user_has_groups('account.group_show_line_subtotals_tax_excluded')
+ user.has_group('account.group_show_line_subtotals_tax_included') and
+ user.has_group('account.group_show_line_subtotals_tax_excluded')
)
if users_with_both_groups:
names = ", ".join(users_with_both_groups.mapped('name'))
diff --git a/addons/account/security/account_security.xml b/addons/account/security/account_security.xml
index bad495b9290..10fdb27f620 100644
--- a/addons/account/security/account_security.xml
+++ b/addons/account/security/account_security.xml
@@ -64,6 +64,17 @@
Add a new payment method
diff --git a/addons/portal/controllers/mail.py b/addons/portal/controllers/mail.py
index 411106dc188..8d1378218a1 100644
--- a/addons/portal/controllers/mail.py
+++ b/addons/portal/controllers/mail.py
@@ -137,7 +137,7 @@ class PortalChatter(http.Controller):
raise Forbidden()
# Non-employee see only messages with not internal subtype (aka, no internal logs)
if not request.env['res.users'].has_group('base.group_user'):
- domain = expression.AND([['&', ('subtype_id', '!=', False), ('subtype_id.internal', '=', False)], domain])
+ domain = expression.AND([['&', '&', ('subtype_id', '!=', False), ('subtype_id.internal', '=', False), ('website_published', '=', True)], domain])
Message = request.env['mail.message'].sudo()
return {
'messages': Message.search(domain, limit=limit, offset=offset).portal_message_format(),
diff --git a/addons/portal/views/portal_templates.xml b/addons/portal/views/portal_templates.xml
index 462a93a5936..f4f88c5dfb2 100644
--- a/addons/portal/views/portal_templates.xml
+++ b/addons/portal/views/portal_templates.xml
@@ -24,7 +24,7 @@