Skip to content

Commit

Permalink
[ADD] sale_order_partner_invoice_period: added last requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
DantePereyra committed Nov 26, 2024
1 parent 6d1e51f commit 9d8c944
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 4 deletions.
3 changes: 2 additions & 1 deletion sale_order_partner_invoice_period/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
],
"data": [
"views/res_partner_view.xml",
"views/sale_order_view.xml"
"views/sale_order_view.xml",
"views/res_config_settings.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,2 +1,3 @@
from . import res_config_settings
from . import res_partner
from . import sale_order
11 changes: 11 additions & 0 deletions sale_order_partner_invoice_period/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# © 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
from .res_partner import INVOICE_PERIOD_SELECTION

class ResCompany(models.Model):
_inherit = "res.company"

default_invoice_period = fields.Selection(
selection=INVOICE_PERIOD_SELECTION
)
22 changes: 22 additions & 0 deletions sale_order_partner_invoice_period/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# © 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 fields, models
from .res_partner import INVOICE_PERIOD_SELECTION

class ResCompany(models.Model):
_inherit = "res.company"

invoice_period_default = fields.Selection(
selection=INVOICE_PERIOD_SELECTION
)

class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'

invoice_period_default = fields.Selection(
selection=INVOICE_PERIOD_SELECTION,
related='company_id.invoice_period_default',
help="Select default invoice period for new companys",
readonly=False
)

17 changes: 14 additions & 3 deletions sale_order_partner_invoice_period/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# © 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
from odoo import models, fields, api

INVOICE_PERIOD_SELECTION = [
('daily','Daily'),
Expand All @@ -11,8 +11,19 @@
('yearly','Yearly')
]


class ResPartner(models.Model):
_inherit = "res.partner"

invoice_period = fields.Selection(INVOICE_PERIOD_SELECTION)
invoice_period = fields.Selection(
selection=INVOICE_PERIOD_SELECTION
)

@api.model
def create(self, vals):
partner = super(ResPartner, self).create(vals)
if not partner.invoice_period:
if partner.is_company:
partner.invoice_period = self.env.company.invoice_period_default
else:
partner.invoice_period = partner.parent_id.invoice_period
return partner
20 changes: 20 additions & 0 deletions sale_order_partner_invoice_period/views/res_config_settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">
res.config.settings.view.form.inherit.sale (in sale_order_partner_invoice_period)
</field>
<field name="model">res.config.settings</field>
<field name="priority" eval="20"/>
<field name="inherit_id" ref="sale.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//setting[@id='automatic_invoicing']" position="after">
<setting id="default_invoice_period" help="Select default invoice period for new companys">
<field name="invoice_period_default"/>
</setting>
</xpath>
</field>
</record>

</odoo>

0 comments on commit 9d8c944

Please sign in to comment.