Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
5361 Lượt xem

Hi,

I want to configure the Invoice due date as 30 days from the date of creating the Invoice.

Suppose I create an invoice today then the due date should be 30 days from today's date automatically.

How can I achieve this?


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

You can do this manually by changing the Due Date or Payment Terms on the invoice itself. 

Now in order to do this automatically you can set Payment Terms per customer.


Ảnh đại diện
Huỷ bỏ
Tác giả

I want to do it automatically. so that, whenever an invoice is created the due date will be 30 days

When you create an invoice and select a customer, the payment term will be set to whatever you defined for that customer. So if you set it to 30 days for a customer then this will be automatically applied to all new invoices for that customer.

Tác giả

I want the due date to be 30 days not a payment term. so that I can follow the invoices as per due date.

If you set the payment term to 30 days then this will also set the due date to 30 days from today. Is there any specific reason you don't want to set the payment term?

Tác giả

Yes, I don't want to use payment terms and It requires code customization.
so whenever a user wants to modify he can go to configuration and change the no. of days there in the setting itself.
As we have for the sales quotation.

Câu trả lời hay nhất

Hi,

Change the _compute_invoice_date_due function
 Try this code:

class AccountMove (models.Model):
    _inherit = 'account.move'

    invoice_date_due = fields.Date(
        string='Due Date',
        compute='_compute_invoice_date_due', store=True, readonly=False,
        index=True,
        copy=False,
    )

    @api.depends('needed_terms')
    def _compute_invoice_date_due(self):
        due_date = fields.Date.context_today(self)+ timedelta(days=30)
        for move in self:
            move.invoice_date_due = move.needed_terms and max(
                (k['date_maturity'] for k in move.needed_terms.keys() if k),
                default=False,
            ) or move.invoice_date_due or due_date


Hope it helps

Ảnh đại diện
Huỷ bỏ
Tác giả

I need help on this

I created a field in the configuration.

from odoo import api, fields, models, _

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

invoice_validity_days = fields.Integer(
related='invoice_date_due.invoice_validity_days',
readonly=False)

@api.onchange('invoice_validity_days')
def _onchange_invoice_validity_days(self):
if self.invoice_validity_days < 0:
self.quotation_validity_days = self.env['res.company'].default_get(
['invoice_validity_days']
)['invoice_validity_days']
return {
'warning': {
'title': _("Warning"),
'message': _("Invoice Validity is required and must be greater or equal to 0."),
},
}

In Views

<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data>
<record id="res_config_settings_view_form_inherit" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit.account</field>
<field name="model">res.config.settings</field>
<field name="priority" eval="40"/>
<field name="inherit_id" ref="account.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//form" position="inside">
<field name="country_code" invisible="1" groups="account.group_account_manager"/>
<app data-string="Invoicing" string="Invoicing" name="account" groups="account.group_account_manager">
<field name="has_chart_of_accounts" invisible="1"/>
<field name="has_accounting_entries" invisible="1"/>
<block title="Customer Invoices" id="invoicing_settings">
<setting id="invoice_validity_days" help="Invoice validity in days">
<field name="invoice_validity_days"/>
</setting>
</block>
</app>
</xpath>
</field>
</record>
</data>
</odoo>

on change in settings, it should appear in invoice.

Please help on this

Tác giả

??

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 7 25
703
1
thg 7 25
751
0
thg 7 25
983
2
thg 7 25
1256
1
thg 6 25
745