Skip to content

Commit

Permalink
[ADD] sale_order_partner_invoice_period
Browse files Browse the repository at this point in the history
Adds a selector of period to invoice directions.
  • Loading branch information
DantePereyra committed Nov 19, 2024
1 parent e8ede3d commit caa2d89
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 7 deletions.
1 change: 1 addition & 0 deletions sale_order_partner_invoice_period/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
],
"data": [
"views/res_partner_view.xml",
"views/sale_order_view.xml"
],
'installable': True,
}
1 change: 1 addition & 0 deletions sale_order_partner_invoice_period/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import res_partner
from . import sale_order
5 changes: 3 additions & 2 deletions sale_order_partner_invoice_period/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
class ResPartner(models.Model):
_inherit = "res.partner"

period=fields.Selection(

invoice_period = fields.Selection(
[
('daily','Daily'),
('weekly','Weekly'),
Expand All @@ -14,4 +15,4 @@ class ResPartner(models.Model):
('quarterly','Quarterly'),
('yearly','Yearly')
]
)
)
12 changes: 12 additions & 0 deletions sale_order_partner_invoice_period/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# © 2024 Solvos Consultoría Informática (<http://www.solvos.es>)
# License LGPL-3 - See http://www.gnu.org/licenses/lgpl-3.0.html
from odoo import models, fields, api

class SaleOrder(models.Model):
_inherit = "sale.order"

partner_invoice_period = fields.Selection(
related='partner_invoice_id.invoice_period',
string="Invoice Period",
store=True
)
7 changes: 2 additions & 5 deletions sale_order_partner_invoice_period/views/res_partner_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='vat']" position="after">
<field name="period" invisible="type != 'invoice'"/>
</xpath>
<xpath expr="//field[@name='child_ids']//field[@name='comment']" position="before">
<field name="period"/>
<field name="invoice_period" invisible="type != 'invoice'"/>
</xpath>
<xpath expr="//field[@name='child_ids']//form//field[@name='mobile']" position="after">
<field name="period" invisible="type != 'invoice'"/>
<field name="invoice_period" invisible="type != 'invoice'"/>
</xpath>
</field>
</record>
Expand Down
41 changes: 41 additions & 0 deletions sale_order_partner_invoice_period/views/sale_order_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="view_order_form_inherit" model="ir.ui.view">
<field name="name">sale.order.view.form.inherit</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='payment_term_id']" position="after">
<field name="partner_invoice_period"/>
</xpath>

</field>
</record>

<record id="view_sales_order_filter_inherit" model="ir.ui.view">
<field name="name">sale.order.searh.inherit</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_sales_order_filter"/>
<field name="arch" type="xml">
<xpath expr="//search" position="inside">
<field name="partner_invoice_period"/>
<filter name="partner_invoice_period" domain="[]" context="{'group_by': 'partner_invoice_period'}"/>
</xpath>

</field>
</record>

<record id="sale_order_tree_inherit" model="ir.ui.view">
<field name="name">sale.order.view.tree.inherit</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.sale_order_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='expected_date']" position="after">
<field name="partner_invoice_period" optional="hide"/>
</xpath>

</field>
</record>

</odoo>

0 comments on commit caa2d89

Please sign in to comment.