Skip to content

Commit

Permalink
[MIG] cooperator_eater: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
robinkeunen committed Oct 24, 2023
1 parent 043f495 commit bc0330a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 34 deletions.
3 changes: 1 addition & 2 deletions cooperator_eater/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
"author": "BEES coop, Coop IT Easy SC",
"website": "https://github.com/beescoop/Obeesdoo",
"category": "Cooperative management",
"version": "12.0.1.1.0",
"version": "16.0.1.0.0",
"depends": [
"eater",
"cooperator",
"partner_contact_birthdate",
"cooperator_worker",
],
Expand Down
8 changes: 2 additions & 6 deletions cooperator_eater/demo/product_share.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- Share products -->
<record id="cooperator_worker.share_a" model="product.product">
<record id="cooperator.product_template_share_type_1_demo" model="product.template">
<field name="max_nb_eater_allowed">3</field>
</record>
<record id="cooperator_worker.share_b" model="product.product">
<record id="cooperator.product_template_share_type_2_demo" model="product.template">
<field name="max_nb_eater_allowed">2</field>
</record>
<record id="cooperator_worker.share_c" model="product.product">
<field name="max_nb_eater_allowed">-1</field>
</record>

</odoo>
1 change: 0 additions & 1 deletion cooperator_eater/models/subscription_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def get_eater_vals(self, partner, share_product_id):

return {"eater": eater}

@api.multi
def validate_subscription_request(self):
self.ensure_one()

Expand Down
26 changes: 8 additions & 18 deletions cooperator_eater/tests/test_eaters.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,17 @@ class TestEaters(TestWorkerBase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))

partner_obj = cls.env["res.partner"]
ptemplate_obj = cls.env["product.template"]

cls.eater_1 = partner_obj.create(
{"name": "Eater 1", "customer": True, "eater": "eater"}
)
cls.eater_2 = partner_obj.create(
{"name": "Eater 2", "customer": True, "eater": "eater"}
)
cls.eater_3 = partner_obj.create(
{"name": "Eater 3", "customer": True, "eater": "eater"}
)
cls.eater_4 = partner_obj.create(
{"name": "Eater 4", "customer": True, "eater": "eater"}
)
cls.eater_1 = partner_obj.create({"name": "Eater 1", "eater": "eater"})
cls.eater_2 = partner_obj.create({"name": "Eater 2", "eater": "eater"})
cls.eater_3 = partner_obj.create({"name": "Eater 3", "eater": "eater"})
cls.eater_4 = partner_obj.create({"name": "Eater 4", "eater": "eater"})

cls.cooperator_x.eater = "worker_eater"
cls.cooperator_y.eater = "worker_eater"
cls.cooperator_z.eater = "worker_eater"

cls.worker_share = ptemplate_obj.create(
{
Expand Down Expand Up @@ -110,16 +100,16 @@ def test_share_with_no_eater_assignment_allowed(self):
"""
Test that share that doesn't allow eater assignment.
"""
self.share_z.max_nb_eater_allowed = 0
self.share_x.max_nb_eater_allowed = 0

max_eater_error_msg = "You can only set 0 additional eaters per worker"
with self.assertRaisesRegex(ValidationError, max_eater_error_msg):
self.cooperator_z.write({"child_eater_ids": [(4, self.eater_1.id)]})
self.cooperator_x.write({"child_eater_ids": [(4, self.eater_1.id)]})

with self.assertRaisesRegex(ValidationError, max_eater_error_msg):
self.eater_1.write({"parent_eater_id": self.cooperator_z.id})
self.eater_1.write({"parent_eater_id": self.cooperator_x.id})

def test_get_eater_vals_returns_share_zonfiguration(self):
def test_get_eater_vals_returns_share_configuration(self):
partner = self.env["res.partner"].create(
{
"name": "Partner with birthdate set",
Expand Down
12 changes: 5 additions & 7 deletions cooperator_eater/views/product_template_views.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="product_template_share_form_view_beesdoo_emc" model="ir.ui.view">
<field name="name">product.template.share.form</field>
<record id="product_template_form_view" model="ir.ui.view">
<field name="name">product_template_form_view</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="cooperator.product_template_form_view" />
<field name="inherit_id" ref="cooperator_worker.product_template_form_view" />
<field name="arch" type="xml">
<field name="customer" position="after">
<field name="allow_shopping" position="after">
<field name="eater" attrs="{'invisible':[('is_share','=',False)]}" />
<field
name="max_nb_eater_allowed"
attrs="{'invisible':[('is_share','=',False)]}"
/>
</field>
<field name="minimum_quantity" position="after">
<field name="eater" attrs="{'invisible':[('is_share','=',False)]}" />
</field>
</field>
</record>
</odoo>

0 comments on commit bc0330a

Please sign in to comment.