9 changed files with 167 additions and 65 deletions
@ -0,0 +1 @@ |
|||
from . import models |
@ -1,15 +1,16 @@ |
|||
{ |
|||
'name': 'Deal Eligible Management', |
|||
'name': 'Custom sale and invoice fields', |
|||
'version': '1.0', |
|||
'summary': 'Module to manage deal eligibles', |
|||
'description': 'Custom module for managing deals and their details in Sales Management.', |
|||
'author': 'Your Name', |
|||
'website': 'https://yourwebsite.com', |
|||
'category': 'Sales', |
|||
'depends': ['base', 'sale', 'account'], |
|||
'depends': ['base', 'sale', 'account','purchase',], |
|||
'data': [ |
|||
'security/ir.model.access.csv', |
|||
'views/deal_eligible_views.xml', |
|||
'views/sale_order_views.xml', |
|||
'views/account_move_views', |
|||
], |
|||
'installable': True, |
|||
'application': True, |
|||
|
@ -0,0 +1,61 @@ |
|||
from odoo import api, fields, models |
|||
|
|||
class AccountMove(models.Model): |
|||
_inherit = 'account.move' |
|||
|
|||
booking_date = fields.Date( |
|||
string='Booking Date', |
|||
tracking=False, |
|||
) |
|||
|
|||
developer_commission = fields.Float( |
|||
string='Broker Commission', |
|||
tracking=True, |
|||
) |
|||
|
|||
buyer = fields.Many2one( |
|||
'res.partner', |
|||
string='Buyer Name', |
|||
tracking=True, |
|||
) |
|||
|
|||
deal_id = fields.Integer( |
|||
string='Deal ID', |
|||
tracking=True, |
|||
) |
|||
|
|||
project = fields.Many2one( |
|||
'product.template', |
|||
string='Project Name', |
|||
tracking=True, |
|||
) |
|||
|
|||
sale_value = fields.Monetary( |
|||
string='Sale Value', |
|||
tracking=True, |
|||
) |
|||
|
|||
unit = fields.Many2one( |
|||
'product.product', |
|||
string='Unit', |
|||
tracking=True, |
|||
) |
|||
|
|||
@api.model |
|||
def create(self, vals): |
|||
# Check if invoice is created from sale order |
|||
if vals.get('move_type') in ['out_invoice', 'out_refund'] and vals.get('invoice_origin'): |
|||
sale_order = self.env['sale.order'].search([ |
|||
('name', '=', vals.get('invoice_origin')) |
|||
], limit=1) |
|||
if sale_order: |
|||
vals.update({ |
|||
'booking_date': sale_order.booking_date, |
|||
'developer_commission': sale_order.developer_commission, |
|||
'buyer': sale_order.buyer.id if sale_order.buyer else False, |
|||
'deal_id': sale_order.deal_id, |
|||
'project': sale_order.project.id if sale_order.project else False, |
|||
'sale_value': sale_order.sale_value, |
|||
'unit': sale_order.unit.id if sale_order.unit else False, |
|||
}) |
|||
return super(AccountMove, self).create(vals) |
@ -1,14 +0,0 @@ |
|||
from odoo import models, fields, api |
|||
|
|||
class DealEligible(models.Model): |
|||
_name = 'deal.eligible' |
|||
_description = 'Deal Eligible' |
|||
|
|||
booking_date = fields.Date(string="Booking Date") |
|||
developer_commission = fields.Float(string="Broker Commission", tracking=True) |
|||
buyer = fields.Many2one('res.partner', string="Buyer Name", tracking=True) |
|||
deal_id = fields.Integer(string="Deal ID", tracking=True) |
|||
project = fields.Many2one('product.template', string="Project Name", tracking=True) |
|||
sale_value = fields.Monetary(string="Sale Value", tracking=True, currency_field='currency_id') |
|||
unit = fields.Many2one('product.product', string="Unit", tracking=True) |
|||
currency_id = fields.Many2one('res.currency', string="Currency") |
@ -0,0 +1,54 @@ |
|||
from odoo import models, fields, api |
|||
from odoo.exceptions import ValidationError |
|||
|
|||
class SaleOrder(models.Model): |
|||
_inherit = 'sale.order' |
|||
|
|||
# Custom fields for deal tracking |
|||
booking_date = fields.Date( |
|||
string='Booking Date', |
|||
tracking=True, |
|||
) |
|||
|
|||
developer_commission = fields.Float( |
|||
string='Broker Commission', |
|||
tracking=True, |
|||
digits=(16, 2), |
|||
) |
|||
|
|||
buyer_id = fields.Many2one( |
|||
'res.partner', |
|||
string='Buyer', |
|||
tracking=True, |
|||
) |
|||
|
|||
deal_id = fields.Integer( |
|||
string='Deal ID', |
|||
tracking=True, |
|||
copy=False, # Don't copy when duplicating record |
|||
) |
|||
|
|||
project_id = fields.Many2one( |
|||
'product.template', |
|||
string='Project Name', |
|||
tracking=True, |
|||
) |
|||
|
|||
sale_value = fields.Monetary( |
|||
string='Sale Value', |
|||
tracking=True, |
|||
currency_field='currency_id', |
|||
) |
|||
|
|||
unit_id = fields.Many2one( |
|||
'product.product', |
|||
string='Unit', |
|||
tracking=True, |
|||
domain="[('product_tmpl_id', '=', project_id)]", # Only show units related to selected project |
|||
) |
|||
|
|||
@api.onchange('project_id') |
|||
def _onchange_project_id(self): |
|||
"""Clear unit selection when project changes""" |
|||
if self.project_id: |
|||
self.unit_id = False |
@ -0,0 +1,26 @@ |
|||
<!-- views/account_move_views.xml --> |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<record id="view_move_form_inherit_custom_fields" model="ir.ui.view"> |
|||
<field name="name">account.move.form.inherit.custom.fields</field> |
|||
<field name="model">account.move</field> |
|||
<field name="inherit_id" ref="account.view_move_form"/> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="//field[@name='partner_id']" position="after"> |
|||
<field name="buyer" attrs="{'invisible': [('move_type', 'not in', ['out_invoice', 'out_refund'])]}"/> |
|||
</xpath> |
|||
|
|||
<xpath expr="//field[@name='payment_reference']" position="after"> |
|||
<field name="booking_date" attrs="{'invisible': [('move_type', 'not in', ['out_invoice', 'out_refund'])]}"/> |
|||
<field name="deal_id" attrs="{'invisible': [('move_type', 'not in', ['out_invoice', 'out_refund'])]}"/> |
|||
</xpath> |
|||
|
|||
<xpath expr="//field[@name='invoice_date']" position="after"> |
|||
<field name="project" attrs="{'invisible': [('move_type', 'not in', ['out_invoice', 'out_refund'])]}"/> |
|||
<field name="unit" attrs="{'invisible': [('move_type', 'not in', ['out_invoice', 'out_refund'])]}"/> |
|||
<field name="sale_value" attrs="{'invisible': [('move_type', 'not in', ['out_invoice', 'out_refund'])]}"/> |
|||
<field name="developer_commission" widget="percentage" attrs="{'invisible': [('move_type', 'not in', ['out_invoice', 'out_refund'])]}"/> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
</odoo> |
@ -1,48 +0,0 @@ |
|||
<odoo> |
|||
<record id="view_deal_eligible_tree" model="ir.ui.view"> |
|||
<field name="name">deal.eligible.tree</field> |
|||
<field name="model">deal.eligible</field> |
|||
<field name="arch" type="xml"> |
|||
<tree> |
|||
<field name="booking_date"/> |
|||
<field name="developer_commission"/> |
|||
<field name="buyer"/> |
|||
<field name="deal_id"/> |
|||
<field name="project"/> |
|||
<field name="sale_value"/> |
|||
<field name="unit"/> |
|||
</tree> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="view_deal_eligible_form" model="ir.ui.view"> |
|||
<field name="name">deal.eligible.form</field> |
|||
<field name="model">deal.eligible</field> |
|||
<field name="arch" type="xml"> |
|||
<form> |
|||
<sheet> |
|||
<group> |
|||
<field name="booking_date"/> |
|||
<field name="developer_commission"/> |
|||
<field name="buyer"/> |
|||
<field name="deal_id"/> |
|||
<field name="project"/> |
|||
<field name="sale_value"/> |
|||
<field name="unit"/> |
|||
</group> |
|||
</sheet> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
|
|||
<menuitem id="menu_deal_eligible_root" name="Deal Management" sequence="10"/> |
|||
|
|||
<menuitem id="menu_deal_eligible" name="Deal Eligibles" parent="menu_deal_eligible_root" action="action_deal_eligible" sequence="10"/> |
|||
|
|||
<record id="action_deal_eligible" model="ir.actions.act_window"> |
|||
<field name="name">Deal Eligibles</field> |
|||
<field name="res_model">deal.eligible</field> |
|||
<field name="view_mode">tree,form</field> |
|||
</record> |
|||
</odoo> |
|||
''' |
@ -0,0 +1,21 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<record id="view_order_form_inherit_deal_tracking" model="ir.ui.view"> |
|||
<field name="name">sale.order.form.deal.tracking</field> |
|||
<field name="model">sale.order</field> |
|||
<field name="inherit_id" ref="sale.view_order_form"/> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="//group[@name='sale_info']" position="after"> |
|||
<group string="Deal Information"> |
|||
<field name="booking_date"/> |
|||
<field name="developer_commission"/> |
|||
<field name="buyer_id"/> |
|||
<field name="deal_id"/> |
|||
<field name="project_id"/> |
|||
<field name="sale_value"/> |
|||
<field name="unit_id"/> |
|||
</group> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
</odoo> |
Loading…
Reference in new issue