Skip to content

Commit

Permalink
[MIG] sale_customer_rank: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
amarcosg committed Jun 6, 2023
1 parent dc3782f commit 412ccd8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
2 changes: 1 addition & 1 deletion sale_customer_rank/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
23 changes: 23 additions & 0 deletions sale_customer_rank/i18n/es.po
Original file line number Diff line number Diff line change
@@ -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"
10 changes: 5 additions & 5 deletions sale_customer_rank/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 1 addition & 3 deletions sale_customer_rank/tests/test_sale_customer_rank.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 412ccd8

Please sign in to comment.