Browse Source

[ADD] agreement.line

pull/242/head
Maxime Chambreuil 6 years ago
parent
commit
215a291eaa
  1. 1
      agreement/models/__init__.py
  2. 10
      agreement/models/agreement.py
  3. 22
      agreement/models/agreement_line.py
  4. 17
      agreement/views/agreement.xml
  5. 19
      agreement/views/res_config_settings.xml

1
agreement/models/__init__.py

@ -6,6 +6,7 @@ from . import (
agreement,
agreement_appendix,
agreement_clause,
agreement_line,
agreement_recital,
agreement_section,
agreement_serviceprofile,

10
agreement/models/agreement.py

@ -279,8 +279,7 @@ class Agreement(models.Model):
string="Appendices", copy=True)
serviceprofile_ids = fields.One2many('agreement.serviceprofile',
'agreement_id',
string="Service Profiles",
readonly=True)
string="Service Profiles")
analytic_id = fields.Many2one('account.analytic.account',
string='Analytic Account', index=True)
analytic_line_ids = fields.One2many('account.analytic.line',
@ -301,11 +300,8 @@ class Agreement(models.Model):
copy=False,
domain=[('active', '=', True)]
)
products_ids = fields.Many2many(
'product.template',
string="Products",
copy=False
)
line_ids = fields.One2many('agreement.line', 'agreement_id',
string="Products/Services", copy=False)
state = fields.Selection([
('draft', 'Draft'),
('active', 'Active'),

22
agreement/models/agreement_line.py

@ -0,0 +1,22 @@
# Copyright (C) 2018 - TODAY, Pavlov Media
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class AgreementLine(models.Model):
_name = 'agreement.line'
_description = 'Agreement Lines'
product_id = fields.Many2one('product.product', string='Product')
name = fields.Char(string="Description", required=True)
agreement_id = fields.Many2one('agreement', string="Agreement",
ondelete="cascade")
qty = fields.Float(string='Quantity')
uom_id = fields.Many2one('product.uom', string='Unit of Measure',
required=True)
@api.onchange('product_id')
def _onchange_product_id(self):
self.name = self.product_id.name
self.uom_id = self.product_id.uom_id.id

17
agreement/views/agreement.xml

@ -163,12 +163,21 @@
</group>
</page>
<page name="products" string="Products/Services">
<group string="Products/Services">
<field name="product_ids" nolabel="1"/>
</group>
<field name="line_ids" nolabel="1">
<tree editable="top">
<field name="product_id"/>
<field name="name"/>
<field name="qty"/>
<field name="uom_id" groups="product.group_uom"/>
</tree>
</field>
</page>
<page name="serviceprofiles" string="Service Profiles">
<field name="serviceprofile_ids" nolabel="1"/>
<field name="serviceprofile_ids" nolabel="1">
<tree editable="top">
<field name="name"/>
</tree>
</field>
</page>
<page name="financials" string="Financials">
<group>

19
agreement/views/res_config_settings.xml

@ -13,6 +13,25 @@
string="Agreements"
data-key="agreement"
groups="agreement.group_agreement_manager">
<h2>Operations</h2>
<div class="row mt16 o_settings_container">
<div class="col-xs-12 col-md-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="group_uom"/>
</div>
<div class="o_setting_right_pane">
<label for="group_uom"/>
<div class="text-muted">
Sell and purchase products in different units of measure
</div>
<div class="content-group">
<div class="mt16" attrs="{'invisible': [('group_uom', '=', False)]}">
<button name="%(product.product_uom_form_action)d" icon="fa-arrow-right" type="action" string="Units Of Measure" class="btn-link"/>
</div>
</div>
</div>
</div>
</div>
<h2>Advanced Features</h2>
<div class="row mt16 o_settings_container">
<div class="col-xs-12 col-md-6 o_setting_box">

Loading…
Cancel
Save