houssine
6 years ago
5 changed files with 138 additions and 0 deletions
-
1easy_my_coop/__openerp__.py
-
52easy_my_coop/view/subscription_request_view.xml
-
1easy_my_coop/wizard/__init__.py
-
48easy_my_coop/wizard/update_share_line.py
-
36easy_my_coop/wizard/update_share_line.xml
@ -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 |
@ -0,0 +1,36 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<data> |
|||
<record id="view_update_partner_info" model="ir.ui.view"> |
|||
<field name="name">Update Share line Info</field> |
|||
<field name="model">share.line.update.info</field> |
|||
<field name="arch" type="xml"> |
|||
<form string="Update Share Line Info"> |
|||
<p class="oe_grey"> |
|||
Update Share Line Info. |
|||
</p> |
|||
<group> |
|||
<field name="cooperator" readonly="True"/> |
|||
<field name="share_line" readonly="True"/> |
|||
<field name="effective_date"/> |
|||
</group> |
|||
<footer> |
|||
<button name="update" string="Update Info" type="object" class="btn-primary"/> |
|||
<button string="Cancel" class="btn-default" special="cancel"/> |
|||
</footer> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="action_view_update_share_line_info" model="ir.actions.act_window"> |
|||
<field name="name">Update Share Line Info</field> |
|||
<field name="type">ir.actions.act_window</field> |
|||
<field name="res_model">share.line.update.info</field> |
|||
<field name="view_type">form</field> |
|||
<field name="view_mode">form</field> |
|||
<field name="target">new</field> |
|||
<field name="groups_id" eval="[(4,ref('easy_my_coop.group_energiris_super_manager'))]"/> |
|||
</record> |
|||
|
|||
</data> |
|||
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue