From 412ccd8119aa7b8de11f59640dbba8364acdb928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro?= Date: Tue, 6 Jun 2023 16:04:51 +0200 Subject: [PATCH] [MIG] sale_customer_rank: Migration to 16.0 --- sale_customer_rank/__manifest__.py | 2 +- sale_customer_rank/i18n/es.po | 23 +++++++++++++++++++ sale_customer_rank/models/sale_order.py | 10 ++++---- .../tests/test_sale_customer_rank.py | 4 +--- 4 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 sale_customer_rank/i18n/es.po diff --git a/sale_customer_rank/__manifest__.py b/sale_customer_rank/__manifest__.py index 809e084eb30..124e322cad5 100644 --- a/sale_customer_rank/__manifest__.py +++ b/sale_customer_rank/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Sale Customer Rank", "summary": "Update Customer Rank when creating a Sale Order", - "version": "14.0.1.0.0", + "version": "16.0.1.0.0", "category": "Sales", "website": "https://github.com/OCA/partner-contact", "author": "ForgeFlow, Odoo Community Association (OCA)", diff --git a/sale_customer_rank/i18n/es.po b/sale_customer_rank/i18n/es.po new file mode 100644 index 00000000000..7139336a2c0 --- /dev/null +++ b/sale_customer_rank/i18n/es.po @@ -0,0 +1,23 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_customer_rank +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-06-06 14:18+0000\n" +"PO-Revision-Date: 2023-06-06 16:18+0200\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"Language: es\n" +"X-Generator: Poedit 2.0.6\n" + +#. module: sale_customer_rank +#: model:ir.model,name:sale_customer_rank.model_sale_order +msgid "Sales Order" +msgstr "Pedido de venta" diff --git a/sale_customer_rank/models/sale_order.py b/sale_customer_rank/models/sale_order.py index 7e9bf434a5f..bc628b1b279 100644 --- a/sale_customer_rank/models/sale_order.py +++ b/sale_customer_rank/models/sale_order.py @@ -7,10 +7,10 @@ class SaleOrder(models.Model): _inherit = "sale.order" - @api.model - def create(self, vals): - res = super().create(vals) - if res: - partners = res.partner_id | res.partner_id.commercial_partner_id + @api.model_create_multi + def create(self, vals_list): + res = super().create(vals_list) + for record in res: + partners = record.partner_id | record.partner_id.commercial_partner_id partners._increase_rank("customer_rank") return res diff --git a/sale_customer_rank/tests/test_sale_customer_rank.py b/sale_customer_rank/tests/test_sale_customer_rank.py index cafb041384f..979c645f660 100644 --- a/sale_customer_rank/tests/test_sale_customer_rank.py +++ b/sale_customer_rank/tests/test_sale_customer_rank.py @@ -7,7 +7,5 @@ class TestCustomerRank(TransactionCase): def test_customer_rank(self): partner = self.env["res.partner"].create({"name": "test partner"}) self.assertEqual(partner.customer_rank, 0) - sale = self.env["sale.order"].create( # noqa: F841 - {"name": "test sale", "partner_id": partner.id} - ) + self.env["sale.order"].create({"name": "test sale", "partner_id": partner.id}) self.assertEqual(partner.customer_rank, 1)