Browse Source

[IMP Views

pull/194/head
Maxime Chambreuil 6 years ago
parent
commit
1e1877e56f
  1. 67
      agreement/__manifest__.py
  2. 13
      agreement/data/ir_sequence.xml
  3. 69
      agreement/models/agreement.py
  4. 8
      agreement/models/res_partner.py
  5. 89
      agreement/views/agreement.xml
  6. 11
      agreement/views/agreement_increasetype.xml
  7. 9
      agreement/views/agreement_renewaltype.xml
  8. 14
      agreement/views/agreement_subtype.xml
  9. 9
      agreement/views/agreement_type.xml
  10. 4
      agreement/views/res_partner.xml

67
agreement/__manifest__.py

@ -2,40 +2,41 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Agreements",
"summary": "Manage Agreements, LOI and Contracts",
"author": "Pavlov Media, "
"Open Source Integrators, "
"Odoo Community Association (OCA)",
"website": "https://github.com/OCA/contract",
"category": "Partner",
"license": "AGPL-3",
"version": "11.0.0.0.1",
"depends": [
"account",
"contacts",
"mail",
"product",
"sale_management",
'name': 'Agreements',
'summary': 'Manage Agreements, LOI and Contracts',
'author': 'Pavlov Media, '
'Open Source Integrators, '
'Odoo Community Association (OCA)',
'website': 'https://github.com/OCA/contract',
'category': 'Partner',
'license': 'AGPL-3',
'version': '11.0.0.0.1',
'depends': [
'account',
'contacts',
'mail',
'product',
'sale_management',
],
"data": [
"data/module_category.xml",
"security/res_groups.xml",
"security/ir.model.access.csv",
'data': [
'data/ir_sequence.xml',
'data/module_category.xml',
'security/res_groups.xml',
'security/ir.model.access.csv',
'views/res_config_settings.xml',
"views/reports.xml",
"views/agreement.xml",
"views/agreement_clause.xml",
"views/agreement_section.xml",
"views/agreement_stages.xml",
"views/agreement_type.xml",
"views/agreement_subtype.xml",
"views/agreement_renewaltype.xml",
"views/agreement_increasetype.xml",
"views/res_partner.xml",
"views/menu.xml",
'views/reports.xml',
'views/agreement.xml',
'views/agreement_clause.xml',
'views/agreement_section.xml',
'views/agreement_stages.xml',
'views/agreement_type.xml',
'views/agreement_subtype.xml',
'views/agreement_renewaltype.xml',
'views/agreement_increasetype.xml',
'views/res_partner.xml',
'views/menu.xml',
],
"application": True,
"development_status": "Beta",
"maintainers": "max3903",
'application': True,
'development_status': 'Beta',
'maintainers': 'max3903',
}

13
agreement/data/ir_sequence.xml

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="1">
<!-- Sequence for agreement -->
<record id="seq_agreement" model="ir.sequence">
<field name="name">Agreements</field>
<field name="code">agreement</field>
<field name="prefix">AG</field>
<field name="padding">3</field>
<field name="company_id" eval="False"/>
</record>
</odoo>

69
agreement/models/agreement.py

@ -1,10 +1,9 @@
# Copyright (C) 2018 - TODAY, Pavlov Media
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields, api
from odoo import api, models, fields, _
# Main Agreement Records Model
class Agreement(models.Model):
_name = 'agreement'
_inherit = ['mail.thread']
@ -99,8 +98,10 @@ class Agreement(models.Model):
help="Total value of the contract over ther entire term.",
store=True
)
contract_id = fields.Char(
string="ID",
reference = fields.Char(
string="Reference",
required=True,
default=lambda self: _('New'),
track_visibility='onchange',
help="ID used for internal contract tracking.")
total_company_mrc = fields.Monetary(
@ -139,54 +140,6 @@ class Agreement(models.Model):
track_visibility='onchange',
help="Date that the contract was terminated."
)
customer_address = fields.Char(
related='customer_id.contact_address',
string="Address"
)
customer_street = fields.Char(
related='customer_id.street',
string="Street"
)
customer_street2 = fields.Char(
related='customer_id.street2',
string="Street 2"
)
customer_city = fields.Char(
related='customer_id.city',
string="City"
)
customer_state_id = fields.Many2one(
related='customer_id.state_id',
string="State"
)
customer_zip = fields.Char(
related='customer_id.zip',
string="Zip"
)
vendor_address = fields.Char(
related='vendor_id.contact_address',
string="Address"
)
vendor_street = fields.Char(
related='vendor_id.street',
string="Street"
)
vendor_street2 = fields.Char(
related='vendor_id.street2',
string="Street 2"
)
vendor_city = fields.Char(
related='vendor_id.city',
string="City"
)
vendor_state_id = fields.Many2one(
related='vendor_id.state_id',
string="State"
)
vendor_zip = fields.Char(
related='vendor_id.zip',
string="Zip"
)
reviewed_date = fields.Date(
string="Reviewed Date",
track_visibility='onchange'
@ -236,7 +189,6 @@ class Agreement(models.Model):
related='customer_contact_id.email',
string="Email"
)
vendor_contact_id = fields.Many2one(
'res.partner',
string="Vendor Contact",
@ -264,6 +216,9 @@ class Agreement(models.Model):
help="Select the sub-type of this agreement. Sub-Types are related to "
"agreement types."
)
product_ids = fields.Many2many(
'product.template',
string="Products & Services")
sale_order_id = fields.Many2one(
'sale.order',
string="Sales Order",
@ -309,7 +264,6 @@ class Agreement(models.Model):
track_visibility='onchange',
help="Describes what happens after the contract expires."
)
order_lines_services_ids = fields.One2many(
related='sale_order_id.order_line',
string="Service Order Lines",
@ -428,6 +382,13 @@ class Agreement(models.Model):
'view_type': 'form',
'res_id': res.id}
@api.model
def create(self, vals):
if vals.get('reference', _('New')) == _('New'):
vals['reference'] = \
self.env['ir.sequence'].next_by_code('agreement') or _('New')
return super(Agreement, self).create(vals)
# Increments the revision on each save action
@api.multi
def write(self, vals):

8
agreement/models/res_partner.py

@ -6,9 +6,5 @@ from odoo import models, fields
class Partner(models.Model):
_inherit = 'res.partner'
agreements_ids = fields.One2many(
'agreement',
'name',
string="Agreements"
)
agreement_ids = fields.One2many('agreement', 'customer_id',
string="Agreements")

89
agreement/views/agreement.xml

@ -36,30 +36,34 @@
<field name="name"/>
</h1>
</div>
<group string="General" colspan="2" col="4">
<field name="contract_id"
string="Internal ID"/>
<group string="General">
<group>
<field name="reference" readonly="1"/>
<field name="parent_agreement_id"
domain="[('customer_id', '=', customer_id)]"/>
<field name="is_template"/>
</group>
<group>
<field name="agreement_type_id"
widget="selection"
required="True"/>
<field name="assigned_user_id"
attrs="{'invisible': [('is_template', '=', True)], 'readonly':[('is_template', '=', True)]}"/>
<field name="agreement_subtype_id"
widget="selection"
domain="[('agreement_type_id', '=', agreement_type_id)]"/>
<field name="assigned_user_id"
attrs="{'invisible': [('is_template', '=', True)], 'readonly':[('is_template', '=', True)]}"/>
<field name="active" invisible="1"/>
<field name="state" invisible="1"/>
</group>
<group>
</group>
<group string="Description">
<field name="description"
string="Description"
required="True"/>
required="True"
nolabel="1"/>
</group>
<group name="customer_vendor_information">
<group name="parties" string="Parties">
<group name="customer_left"
string="Customer Information">
string="Customer">
<div class="o_address_format">
<field name="customer_id"
domain="[('customer', '=', True)]"
@ -68,7 +72,7 @@
</div>
</group>
<group name="vendor_right"
string="Vendor Information">
string="Vendor">
<div class="o_address_format">
<field name="vendor_id"
domain="[('supplier', '=', True)]"
@ -105,8 +109,9 @@
<field name="increase_type_id" widget="selection"/>
</group>
</group>
<group>
<field name="special_terms"/>
<group string="Special Terms">
<field name="special_terms"
nolabel="1"/>
</group>
<notebook>
<page name="structure" string="Structure">
@ -114,16 +119,20 @@
<button name="%(partner_agreement_contract_document_preview)d" string="Preview" type="action" class="oe_highlight"/>
<button name="%(partner_agreement_contract_document)d" string="Print" type="action" class="oe_highlight"/>
</div>
<group colspan="2" col="2" default_order='section_sequence'>
<field name="sections_ids" string="Contract Sections" context="{'default_agreement': active_id}">
<group string="Sections" default_order='section_sequence'>
<field name="sections_ids"
nolabel="1"
context="{'default_agreement': active_id}">
<tree default_order='section_sequence'>
<field name="section_sequence" widget="handle"/>
<field name="name"/>
</tree>
</field>
</group>
<group colspan="2" col="2" default_order='section_id, clause_sequence'>
<field name="clauses_ids" string="Contract Clauses" context="{'default_agreement': active_id}">
<group string="Clauses" default_order='section_id, clause_sequence'>
<field name="clauses_ids"
nolabel="1"
context="{'default_agreement': active_id}">
<tree default_order='section_id, clause_sequence'>
<field name="clause_sequence" widget="handle"/>
<field name="section_id"/>
@ -133,32 +142,39 @@
</group>
</page>
<page name="signature" string="Signatures">
<group colspan="2" col="4">
<field name="customer_signed_date"/>
<group>
<group string="Company">
<field name="company_signed_date"/>
<field name="customer_signed_user_id" domain="[('parent_id', '=', customer_id)]"/>
<field name="company_signed_user_id"/>
<field name="signed_contract" filename="signed_contract_filename"/>
<field name="signed_contract_filename" invisible="1"/>
</group>
<group string="Customer">
<field name="customer_signed_date"/>
<field name="customer_signed_user_id" domain="[('parent_id', '=', customer_id)]"/>
</group>
</group>
</page>
<page name="products" string="MRC and NRC Products">
<group string="Financial Details" colspan="2" col="4">
<page name="products" string="Products/Services">
<group>
<field name="product_ids" nolabel="1"/>
</group>
</page>
<page name="costs" string="Costs">
<group string="Financial Details">
<group string="Company">
<field name="total_company_mrc"/>
<field name="total_customer_mrc"/>
<field name="total_company_nrc"/>
<field name="total_customer_nrc"/>
<field name="currency_id"/>
<field name="contract_value" readonly="1"/>
</group>
<group>
<field name="sale_order_id" domain="[('partner_id', '=', customer_id)]"/>
<group string="Customer">
<field name="total_customer_mrc"/>
<field name="total_customer_nrc"/>
</group>
<group string="Sales Order Lines">
<field name="order_lines_services_ids" nolabel="1" readonly="1"/>
</group>
</page>
<page colspan="2" col="4" name="child_agreements" string="Child Agreements">
<page name="child_agreements" string="Child Agreements">
<field name="child_agreements_ids">
<tree default_order='version desc'>
<field name="name"/>
@ -167,7 +183,7 @@
</tree>
</field>
</page>
<page colspan="2" col="4" name="old_versions" string="Revisions">
<page name="old_versions" string="Revisions">
<field name="previous_version_agreements_ids" string="Previouse Versions">
<tree default_order='version desc'>
<field name="name"/>
@ -176,17 +192,16 @@
</tree>
</field>
</page>
<page colspan="2" col="4" name="peformance" string="Performance">
<page name="peformance" string="Performance">
<p>This section is a place where financial records will show the current performance of this agreement.</p>
<p>Perhaps include invoices with total vs costs? </p>
</page>
</notebook>
<group colspan="2" col="4" string="Administration">
<field name="reviewed_date"/>
<field name="approved_date"/>
<field name="reviewed_user_id"/>
<field name="approved_user_id"/>
<field name="is_template"/>
<group string="Administration">
<div>
<p>Reviewed by <field name="reviewed_user_id" class="oe_inline"/> on <field name="reviewed_date" class="oe_inline"/>.</p>
<p>Approved by <field name="approved_user_id" class="oe_inline"/> on <field name="approved_date" class="oe_inline"/>.</p>
</div>
</group>
<footer>
Version: <field name="version" readonly="True"/>.<field name="revision" readonly="True"/>

11
agreement/views/agreement_increasetype.xml

@ -21,14 +21,15 @@
<field name="arch" type="xml">
<form string="Agreements Type Form">
<sheet>
<div class="oe_title">
<label for="name" class="oe_edit_only" string="Type"/>
<h1><field name="name"/></h1>
</div>
<group>
<field name="description"/>
<field name="name"/>
</group>
<group>
<field name="increase_percent"/>
</group>
<group string="Description">
<field name="description" nolabel="1"/>
</group>
</sheet>
</form>
</field>

9
agreement/views/agreement_renewaltype.xml

@ -20,12 +20,11 @@
<field name="arch" type="xml">
<form string="Agreements Type Form">
<sheet>
<div class="oe_title">
<label for="name" class="oe_edit_only" string="Type"/>
<h1><field name="name"/></h1>
</div>
<group>
<field name="description"/>
<field name="name"/>
</group>
<group string="Description">
<field name="description" nolabel="1"/>
</group>
</sheet>
</form>

14
agreement/views/agreement_subtype.xml

@ -18,14 +18,14 @@
<field name="name">Agreement Sub Type Form</field>
<field name="model">agreement.subtype</field>
<field name="arch" type="xml">
<form string="Agreements Sub Type Form">
<form string="Agreement Sub-Types">
<sheet>
<div class="oe_title">
<label for="name" class="oe_edit_only" string="Sub-Type Name"/>
<h1><field name="name" string="Sub-Type Name"/></h1>
</div>
<group>
<field name="agreement_type_id" string="Agreement Type" required="True"/>
<field name="name"/>
</group>
<group>
<field name="agreement_type_id"
required="True"/>
</group>
</sheet>
</form>
@ -34,7 +34,7 @@
<!-- Actions opening views on models -->
<record model="ir.actions.act_window" id="partner_agreement_action_subtype">
<field name="name">Agreement Sub Type</field>
<field name="name">Agreement Sub-Types</field>
<field name="res_model">agreement.subtype</field>
<field name="view_mode">tree,form</field>
</record>

9
agreement/views/agreement_type.xml

@ -20,12 +20,11 @@
<field name="arch" type="xml">
<form string="Agreements Type Form">
<sheet>
<div class="oe_title">
<label for="name" class="oe_edit_only" string="Type"/>
<h1><field name="name" string="Type Name"/></h1>
</div>
<group>
<field name="agreement_subtypes_ids" string="Sub-Types"/>
<field name="name"/>
</group>
<group string="Sub-Types">
<field name="agreement_subtypes_ids" nolabel="1"/>
</group>
</sheet>
</form>

4
agreement/views/res_partner.xml

@ -7,8 +7,8 @@
<field name="arch" type="xml">
<xpath expr="//page[@name='internal_notes']" position="after">
<page name="agreement" string="Agreements">
<group colspan="2" col="2">
<field name="agreements_ids" string="Agreements" />
<group>
<field name="agreement_ids" nolabel="1"/>
</group>
</page>
</xpath>

Loading…
Cancel
Save