Browse Source

[CHG] b_base: Remove cooperator_type info

This new b_base module focus on adding member cards and eater
functionality.

Constrain about number of eater should be customise for each
cooperative. And if the cooperative is using easy_my_coop module the
maximum number of eater should be specified on the share product.

Also cooperator_type has no meaning here. For cooperative that uses
easy_my_coop, cooperator_type is a computed field based on the share
that the cooperator owns.

beesdoo_easy_my_coop and beesdoo_worker_status will be modified for
taking this into account.
pull/134/head
Rémy Taymans 5 years ago
parent
commit
53719aaba1
  1. 1
      beesdoo_base/__manifest__.py
  2. 43
      beesdoo_base/demo/eaters.xml
  3. 33
      beesdoo_base/models/partner.py
  4. 20
      beesdoo_base/views/partner.xml

1
beesdoo_base/__manifest__.py

@ -34,5 +34,6 @@
'installable': True, 'installable': True,
'demo': [ 'demo': [
'demo/cooperators.xml', 'demo/cooperators.xml',
'demo/eaters.xml',
] ]
} }

43
beesdoo_base/demo/eaters.xml

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2019 Coop IT Easy
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="eater1" model="res.partner">
<field name="name">Gilles Eaterbeek</field>
<field name="firstname">Gilles</field>
<field name="lastname">Eaterbeek</field>
<field name="eater">eater</field>
<field name="is_company" eval="False"/>
<field name="customer" eval="True"/>
</record>
<record id="eater2" model="res.partner">
<field name="name">Constant Eateration</field>
<field name="firstname">Constant</field>
<field name="lastname">Eateration</field>
<field name="eater">eater</field>
<field name="is_company" eval="False"/>
<field name="customer" eval="True"/>
</record>
<record id="eater3" model="res.partner">
<field name="name">Alexander G. Eaterphone</field>
<field name="firstname">Alexander G.</field>
<field name="lastname">Eaterphone</field>
<field name="eater">eater</field>
<field name="is_company" eval="False"/>
<field name="customer" eval="True"/>
</record>
<record id="eater4" model="res.partner">
<field name="name">Tim Eaternet</field>
<field name="firstname">Tim</field>
<field name="lastname">Eaternet</field>
<field name="eater">eater</field>
<field name="is_company" eval="False"/>
<field name="customer" eval="True"/>
</record>
</odoo>

33
beesdoo_base/models/partner.py

@ -12,40 +12,19 @@ class Partner(models.Model):
barcode = fields.Char(compute="_get_bar_code", string='Barcode', store=True) barcode = fields.Char(compute="_get_bar_code", string='Barcode', store=True)
parent_barcode = fields.Char(compute="_get_bar_code", string='Parent Barcode', store=True) parent_barcode = fields.Char(compute="_get_bar_code", string='Parent Barcode', store=True)
member_card_ids = fields.One2many('member.card', 'partner_id') member_card_ids = fields.One2many('member.card', 'partner_id')
country_id = fields.Many2one(required=True)
member_card_to_be_printed = fields.Boolean('Print BEES card?') member_card_to_be_printed = fields.Boolean('Print BEES card?')
last_printed = fields.Datetime('Last printed on') last_printed = fields.Datetime('Last printed on')
cooperator_type = fields.Selection([('share_a', 'Share A'), ('share_b', 'Share B'), ('share_c', 'Share C')], store=True, compute=None)
@api.depends('parent_eater_id', 'parent_eater_id.barcode', 'eater', 'member_card_ids') @api.depends('parent_eater_id', 'parent_eater_id.barcode', 'eater', 'member_card_ids')
def _get_bar_code(self): def _get_bar_code(self):
self.ensure_one()
if self.eater == 'eater':
self.parent_barcode = self.parent_eater_id.barcode
elif self.member_card_ids:
for c in self.member_card_ids:
for rec in self:
if rec.eater == 'eater':
rec.parent_barcode = rec.parent_eater_id.barcode
elif rec.member_card_ids:
for c in rec.member_card_ids:
if c.valid: if c.valid:
self.barcode = c.barcode
@api.constrains('child_eater_ids', 'parent_eater_id')
def _check_number_of_eaters(self):
"""The owner of an A share can have a maximum of two eaters but
the owner of a B share can have a maximum of three eaters.
"""
self.ensure_one()
# Get the default_code of the share for the current eater and his parent
share_type_code = self.cooperator_type
parent_share_type_code = self.parent_eater_id.cooperator_type
# Raise exception
if share_type_code == 'share_b' or parent_share_type_code == 'share_b':
if len(self.child_eater_ids) > 3 or len(self.parent_eater_id.child_eater_ids) > 3:
raise ValidationError(_('You can only set three additional eaters per worker'))
else:
if len(self.child_eater_ids) > 2 or len(self.parent_eater_id.child_eater_ids) > 2:
raise ValidationError(_('You can only set two additional eaters per worker'))
rec.barcode = c.barcode
@api.multi @api.multi
def write(self, values): def write(self, values):

20
beesdoo_base/views/partner.xml

@ -19,19 +19,12 @@
<field name="model">res.partner</field> <field name="model">res.partner</field>
<field name="inherit_id" ref="point_of_sale.view_partner_property_form" /> <field name="inherit_id" ref="point_of_sale.view_partner_property_form" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="type" position="before">
<field name="cooperator_type"/>
</field>
<field name="website" position="after"> <field name="website" position="after">
<field name="eater" <field name="eater"
attrs="{'invisible': [('customer', '=', False)]}" /> attrs="{'invisible': [('customer', '=', False)]}" />
<field name="parent_eater_id" <field name="parent_eater_id"
attrs="{'invisible' : [('eater', '!=', 'eater')]}" /> attrs="{'invisible' : [('eater', '!=', 'eater')]}" />
</field> </field>
<xpath expr="//notebook/page[1]" position="attributes">
<attribute name="attrs">{'invisible':
[('cooperator_type', '=', 'share_a')]}</attribute>
</xpath>
<xpath expr="//notebook" position="inside"> <xpath expr="//notebook" position="inside">
<page string="Member Card" <page string="Member Card"
attrs="{'invisible': ['|', ('customer', '=', False), ('eater', 'not in', ('worker_eater', 'eater'))]}"> attrs="{'invisible': ['|', ('customer', '=', False), ('eater', 'not in', ('worker_eater', 'eater'))]}">
@ -87,19 +80,6 @@
</field> </field>
</record> </record>
<record model="ir.ui.view" id="beesdoo_partner_search_view">
<field name="name">beesdoo.partner.search.view</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_res_partner_filter" />
<field name="arch" type="xml">
<filter name="type_person" position="after">
<filter name="type_a" string="Cooperator type A" domain="[('cooperator_type', '=', 'share_a')]" />
<filter name="type_b" string="Cooperator type B" domain="[('cooperator_type', '=', 'share_b')]" />
<filter name="type_c" string="Cooperator type C" domain="[('cooperator_type', '=', 'share_c')]" />
</filter>
</field>
</record>
<!-- S022 : By default a supplier should be a company --> <!-- S022 : By default a supplier should be a company -->
<record id="base.action_partner_supplier_form" model="ir.actions.act_window"> <record id="base.action_partner_supplier_form" model="ir.actions.act_window">

Loading…
Cancel
Save