diff --git a/easy_my_coop/__openerp__.py b/easy_my_coop/__openerp__.py index 0da25ed..d9cef39 100644 --- a/easy_my_coop/__openerp__.py +++ b/easy_my_coop/__openerp__.py @@ -49,6 +49,7 @@ 'wizard/create_subscription_from_partner.xml', 'wizard/update_partner_info.xml', 'wizard/validate_subscription_request.xml', + 'wizard/update_share_line.xml', 'view/subscription_request_view.xml', 'view/email_template_view.xml', 'view/res_partner_view.xml', diff --git a/easy_my_coop/view/subscription_request_view.xml b/easy_my_coop/view/subscription_request_view.xml index 0655324..19ba91d 100644 --- a/easy_my_coop/view/subscription_request_view.xml +++ b/easy_my_coop/view/subscription_request_view.xml @@ -160,5 +160,57 @@ + + + share.line.form + share.line + +
+
+
+ + + + + + + + + + + + + + + +
+
+
+ + + share.line.tree + share.line + + + + + + + + + + + + + + + Share Lines + share.line + form + + + \ No newline at end of file diff --git a/easy_my_coop/wizard/__init__.py b/easy_my_coop/wizard/__init__.py index 63034ca..7141024 100644 --- a/easy_my_coop/wizard/__init__.py +++ b/easy_my_coop/wizard/__init__.py @@ -2,3 +2,4 @@ from . import create_subscription_from_partner from . import update_partner_info from . import validate_subscription_request +from . import update_share_line diff --git a/easy_my_coop/wizard/update_share_line.py b/easy_my_coop/wizard/update_share_line.py new file mode 100644 index 0000000..9a5f377 --- /dev/null +++ b/easy_my_coop/wizard/update_share_line.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- + +from openerp import api, fields, models +from openerp.exceptions import UserError + + +class PartnerUpdateInfo(models.TransientModel): + _name = "share.line.update.info" + + @api.model + def _get_share_line(self): + active_id = self.env.context.get('active_id') + return self.env['share.line'].browse(active_id) + + @api.model + def _get_effective_date(self): + share_line = self._get_share_line() + + return share_line.effective_date + + effective_date = fields.Date(string="effective date", + required=True, + default=_get_effective_date) + cooperator = fields.Many2one(related='share_line.partner_id', + string="Cooperator") + share_line = fields.Many2one('share.line', + string="Share line", + default=_get_share_line) + + @api.multi + def update(self): + + line = self.share_line + cooperator = line.partner_id + + sub_reg = self.env['subscription.register'].search( + [('partner_id', '=', cooperator.id), + ('share_product_id', '=', line.share_product_id.id), + ('quantity', '=', line.share_number), + ('date', '=', line.effective_date)]) + if sub_reg: + if len(sub_reg) > 1: + raise UserError(_("Error the update return more than one" + " subscription register lines.")) + else: + line.effective_date = self.effective_date + sub_reg.date = self.effective_date + return True diff --git a/easy_my_coop/wizard/update_share_line.xml b/easy_my_coop/wizard/update_share_line.xml new file mode 100644 index 0000000..c8b1213 --- /dev/null +++ b/easy_my_coop/wizard/update_share_line.xml @@ -0,0 +1,36 @@ + + + + + Update Share line Info + share.line.update.info + +
+

+ Update Share Line Info. +

+ + + + + +
+
+
+
+
+ + + Update Share Line Info + ir.actions.act_window + share.line.update.info + form + form + new + + + +
+
\ No newline at end of file