diff --git a/beesdoo_base/models/partner.py b/beesdoo_base/models/partner.py
index 2b63851..1bf0371 100644
--- a/beesdoo_base/models/partner.py
+++ b/beesdoo_base/models/partner.py
@@ -39,9 +39,25 @@ class Partner(models.Model):
@api.one
@api.constrains('child_eater_ids', 'parent_eater_id')
- def _only_two_eaters(self):
- 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'))
+ 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.
+ """
+ # Get the default_code of the share for the current eater and his parent
+ share_type_code = None
+ parent_share_type_code = None
+ for line in self.share_ids:
+ share_type_code = line.share_product_id.default_code
+ for line in self.parent_eater_id.share_ids:
+ parent_share_type_code = line.share_product_id.default_code
+ # 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'))
+
@api.multi
def write(self, values):
@@ -89,4 +105,4 @@ class Partner(models.Model):
'email' : email,
'country_id' : self.country_id.id
}
- return self.env['res.partner'].create(partner_data)
\ No newline at end of file
+ return self.env['res.partner'].create(partner_data)
diff --git a/beesdoo_pos/__openerp__.py b/beesdoo_pos/__openerp__.py
index 73c469c..8545532 100644
--- a/beesdoo_pos/__openerp__.py
+++ b/beesdoo_pos/__openerp__.py
@@ -20,7 +20,7 @@
'version': '0.1',
# any module necessary for this one to work correctly
- 'depends': ['beesdoo_base', 'beesdoo_product'],
+ 'depends': ['beesdoo_base', 'beesdoo_product', 'easy_my_coop'],
# always loaded
'data': [
diff --git a/beesdoo_pos/models/beesdoo_pos.py b/beesdoo_pos/models/beesdoo_pos.py
index e67aa70..9ec4acf 100644
--- a/beesdoo_pos/models/beesdoo_pos.py
+++ b/beesdoo_pos/models/beesdoo_pos.py
@@ -44,12 +44,14 @@ class BeescoopPosPartner(models.Model):
_inherit = 'res.partner'
def _get_eater(self):
- eater1, eater2 = False, False
+ eater1, eater2, eater3 = False, False, False
if self.child_eater_ids:
eater1 = self.child_eater_ids[0].name
if len(self.child_eater_ids) > 1:
eater2 = self.child_eater_ids[1].name
- return eater1, eater2
+ if len(self.child_eater_ids) > 2:
+ eater3 = self.child_eater_ids[2].name
+ return eater1, eater2, eater3
@api.multi
def get_balance_and_eater(self):
@@ -59,7 +61,7 @@ class BeescoopPosPartner(models.Model):
move_lines = self.env['account.move.line'].search([('account_id', '=', account_id), ('partner_id', '=', self.id)])
credit = sum([m.credit for m in move_lines])
debit = sum([m.debit for m in move_lines])
- eater1, eater2 = self._get_eater()
- return str(round(credit - debit, 2)), eater1, eater2
+ eater1, eater2, eater3 = self._get_eater()
+ return str(round(credit - debit, 2)), eater1, eater2, eater3
last_name = fields.Char('Last Name', required=True, default="/")
diff --git a/beesdoo_pos/static/src/js/beesdoo.js b/beesdoo_pos/static/src/js/beesdoo.js
index 7d483c9..a6054b7 100644
--- a/beesdoo_pos/static/src/js/beesdoo.js
+++ b/beesdoo_pos/static/src/js/beesdoo.js
@@ -59,6 +59,7 @@ odoo.define('beescoop.pos', function (require) {
set_customer_info.call(self, '.customer-balance', result[0])
set_customer_info.call(self, '.customer-delegate1', result[1], 'Eater 1: ');
set_customer_info.call(self, '.customer-delegate2', result[2], 'Eater 2: ');
+ set_customer_info.call(self, '.customer-delegate3', result[3], 'Eater 3: ');
}, function(err) {
loaded.reject(err);
});
@@ -79,6 +80,7 @@ odoo.define('beescoop.pos', function (require) {
set_customer_info.call(self, '.customer-balance', result[0]);
set_customer_info.call(self, '.customer-delegate1', result[1], 'Eater 1: ');
set_customer_info.call(self, '.customer-delegate2', result[2], 'Eater 2: ');
+ set_customer_info.call(self, '.customer-delegate3', result[3], 'Eater 3: ');
}, function(err) {
loaded.reject(err);
});
@@ -92,4 +94,4 @@ odoo.define('beescoop.pos', function (require) {
this.render_customer_info();
},
});
-});
\ No newline at end of file
+});
diff --git a/beesdoo_pos/static/src/xml/templates.xml b/beesdoo_pos/static/src/xml/templates.xml
index a1a8744..1051fc1 100644
--- a/beesdoo_pos/static/src/xml/templates.xml
+++ b/beesdoo_pos/static/src/xml/templates.xml
@@ -22,6 +22,7 @@
+
@@ -37,12 +38,12 @@
€
- Eater 1:
- Eater 2:
+
+
@@ -52,4 +53,4 @@
-
\ No newline at end of file
+