From 787361ed35998efc7ee0d93efbecc1190bec794e Mon Sep 17 00:00:00 2001 From: houssine Date: Thu, 20 Dec 2018 14:45:37 +0100 Subject: [PATCH] [PEP8] comply to pep8 --- easy_my_coop/__openerp__.py | 1 + easy_my_coop/wizard/update_partner_info.py | 24 +++++++----- .../wizard/validate_subscription_request.py | 17 ++++++++ .../wizard/validate_subscription_request.xml | 39 +++++++++++++++++++ 4 files changed, 72 insertions(+), 9 deletions(-) create mode 100644 easy_my_coop/wizard/validate_subscription_request.py create mode 100644 easy_my_coop/wizard/validate_subscription_request.xml diff --git a/easy_my_coop/__openerp__.py b/easy_my_coop/__openerp__.py index f14367f..472d2ab 100644 --- a/easy_my_coop/__openerp__.py +++ b/easy_my_coop/__openerp__.py @@ -48,6 +48,7 @@ 'security/ir.model.access.csv', 'wizard/create_subscription_from_partner.xml', 'wizard/update_partner_info.xml', + 'wizard/validate_subscription_request.xml', 'view/subscription_request_view.xml', 'view/email_template_view.xml', 'view/res_partner_view.xml', diff --git a/easy_my_coop/wizard/update_partner_info.py b/easy_my_coop/wizard/update_partner_info.py index dce4516..100125f 100644 --- a/easy_my_coop/wizard/update_partner_info.py +++ b/easy_my_coop/wizard/update_partner_info.py @@ -3,6 +3,7 @@ from openerp import api, fields, models, _ from openerp.exceptions import UserError + class PartnerUpdateInfo(models.TransientModel): _name = "partner.update.info" _description = "Update Partner Info" @@ -11,7 +12,7 @@ class PartnerUpdateInfo(models.TransientModel): def _get_partner(self): active_id = self.env.context.get('active_id') return self.env['res.partner'].browse(active_id) - + @api.model def _get_register_number(self): partner = self._get_partner() @@ -19,28 +20,33 @@ class PartnerUpdateInfo(models.TransientModel): return partner.company_register_number else: return partner.national_register_number - - register_number = fields.Char(string="Register Number", required=True, default=_get_register_number) - cooperator = fields.Many2one('res.partner', string="Cooperator", default=_get_partner) - + + register_number = fields.Char(string="Register Number", + required=True, + default=_get_register_number) + cooperator = fields.Many2one('res.partner', + string="Cooperator", + default=_get_partner) + def check_belgian_ident_id(self, register_number): - if self.env['subscription.request'].check_belgian_identification_id(register_number): + if self.env['subscription.request'].check_belgian_identification_id( + register_number): return True else: raise UserError(_("The national register number is not valid.")) @api.multi def update(self): - + cooperator = self.cooperator coop_vals = {} - + if cooperator.is_company: coop_vals['company_register_number'] = self.register_number else: if self.check_belgian_ident_id(self.register_number): coop_vals['national_register_number'] = self.register_number - + if coop_vals: cooperator.write(coop_vals) diff --git a/easy_my_coop/wizard/validate_subscription_request.py b/easy_my_coop/wizard/validate_subscription_request.py new file mode 100644 index 0000000..3a2dbb5 --- /dev/null +++ b/easy_my_coop/wizard/validate_subscription_request.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- + +from openerp import api, fields, models, _ +from openerp.exceptions import UserError + + +class ValidateSubscriptionRequest(models.TransientModel): + _name = "validate.subscription.request" + _description = "Update Partner Info" + + @api.multi + def validate(self): + + subscription_requests = self.filtered(lambda record: record.state in ['draft', 'waiting']) + for subscription_request in subscription_requests: + subscription_request.validate_subscription_request + return True diff --git a/easy_my_coop/wizard/validate_subscription_request.xml b/easy_my_coop/wizard/validate_subscription_request.xml new file mode 100644 index 0000000..d952da9 --- /dev/null +++ b/easy_my_coop/wizard/validate_subscription_request.xml @@ -0,0 +1,39 @@ + + + + + Validate subscription request + validate.subscription.request + +
+

+ Validate the subscription request. +

+
+
+
+
+
+ + + Update Cooperator Info + ir.actions.act_window + validate.subscription.request + form + form + new + + + + + + Subscription Request + client_action_multi + + action + subscription.request + +
+