Browse Source

[IMP] add a wizard allowing to correct the effective date.

pull/1/head
houssine 6 years ago
parent
commit
a3841a6223
  1. 1
      easy_my_coop/__openerp__.py
  2. 52
      easy_my_coop/view/subscription_request_view.xml
  3. 1
      easy_my_coop/wizard/__init__.py
  4. 48
      easy_my_coop/wizard/update_share_line.py
  5. 36
      easy_my_coop/wizard/update_share_line.xml

1
easy_my_coop/__openerp__.py

@ -49,6 +49,7 @@
'wizard/create_subscription_from_partner.xml', 'wizard/create_subscription_from_partner.xml',
'wizard/update_partner_info.xml', 'wizard/update_partner_info.xml',
'wizard/validate_subscription_request.xml', 'wizard/validate_subscription_request.xml',
'wizard/update_share_line.xml',
'view/subscription_request_view.xml', 'view/subscription_request_view.xml',
'view/email_template_view.xml', 'view/email_template_view.xml',
'view/res_partner_view.xml', 'view/res_partner_view.xml',

52
easy_my_coop/view/subscription_request_view.xml

@ -160,5 +160,57 @@
</record> </record>
<menuitem action="company_subscription_request_action" name="Company Subscription" id="menu_easy_my_coop_company_subscription_request" parent="menu_easy_my_coop_main_subscription" sequence="12"/> <menuitem action="company_subscription_request_action" name="Company Subscription" id="menu_easy_my_coop_company_subscription_request" parent="menu_easy_my_coop_main_subscription" sequence="12"/>
<record id="share_line_form" model="ir.ui.view">
<field name="name">share.line.form</field>
<field name="model">share.line</field>
<field name="arch" type="xml">
<form string="Share line">
<header>
<button string="Update info" name="%(action_view_update_share_line_info)d"
type="action" context="{'default_active_id': active_id}" groups="easy_my_coop.group_energiris_super_manager"/>
</header>
<sheet>
<group>
<group>
<field name="partner_id"/>
<field name="share_product_id"/>
<field name="share_number"/>
</group>
<group>
<field name="share_short_name"/>
<field name="share_unit_price"/>
<field name="effective_date"/>
<field name="total_amount_line"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
<record id="share_line_tree" model="ir.ui.view">
<field name="name">share.line.tree</field>
<field name="model">share.line</field>
<field name="arch" type="xml">
<tree>
<field name="partner_id"/>
<field name="share_product_id"/>
<field name="share_number"/>
<field name="share_short_name"/>
<field name="share_unit_price"/>
<field name="effective_date"/>
<field name="total_amount_line"/>
</tree>
</field>
</record>
<record id="share_line_action" model="ir.actions.act_window">
<field name="name">Share Lines</field>
<field name="res_model">share.line</field>
<field name="view_type">form</field>
</record>
<menuitem action="share_line_action" name="Share lines" id="menu_easy_my_coop_share_line" parent="menu_easy_my_coop_main_subscription" sequence="20" groups="group_energiris_super_manager"/>
</data> </data>
</openerp> </openerp>

1
easy_my_coop/wizard/__init__.py

@ -2,3 +2,4 @@
from . import create_subscription_from_partner from . import create_subscription_from_partner
from . import update_partner_info from . import update_partner_info
from . import validate_subscription_request from . import validate_subscription_request
from . import update_share_line

48
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

36
easy_my_coop/wizard/update_share_line.xml

@ -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>
Loading…
Cancel
Save