Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master account terms conditions move mgh #30140

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion addons/account/models/account_invoice.py
Expand Up @@ -97,6 +97,11 @@ def _default_currency(self):
journal = self._default_journal()
return journal.currency_id or journal.company_id.currency_id or self.env.user.company_id.currency_id

def _default_comment(self):
invoice_type = self.env.context.get('type', 'out_invoice')
if invoice_type == 'out_invoice' and self.env['ir.config_parameter'].sudo().get_param('account.use_invoice_terms'):
return self.env.user.company_id.invoice_terms

@api.one
@api.depends(
'state', 'currency_id', 'invoice_line_ids.price_subtotal',
Expand Down Expand Up @@ -255,7 +260,7 @@ def _compute_payments(self):
help="Technical field holding the number given to the invoice, automatically set when the invoice is validated then stored to set the same number again if the invoice is cancelled, set to draft and re-validated.")
reference = fields.Char(string='Payment Ref.', copy=False, readonly=True, states={'draft': [('readonly', False)]},
help='The payment communication that will be automatically populated once the invoice validation. You can also write a free communication.')
comment = fields.Text('Additional Information', readonly=True, states={'draft': [('readonly', False)]})
comment = fields.Text('Additional Information', readonly=True, states={'draft': [('readonly', False)]}, default=_default_comment)

state = fields.Selection([
('draft','Draft'),
Expand Down
1 change: 1 addition & 0 deletions addons/account/models/company.py
Expand Up @@ -104,6 +104,7 @@ def _get_invoice_reference_types(self):
# account dashboard onboarding
account_invoice_onboarding_state = fields.Selection([('not_done', "Not done"), ('just_done', "Just done"), ('done', "Done"), ('closed', "Closed")], string="State of the account invoice onboarding panel", default='not_done')
account_dashboard_onboarding_state = fields.Selection([('not_done', "Not done"), ('just_done', "Just done"), ('done', "Done"), ('closed', "Closed")], string="State of the account dashboard onboarding panel", default='not_done')
invoice_terms = fields.Text(string='Default Terms and Conditions', translate=True)

@api.constrains('account_opening_date', 'fiscalyear_last_day', 'fiscalyear_last_month')
def _check_fiscalyear_last_day(self):
Expand Down
5 changes: 5 additions & 0 deletions addons/account/models/res_config_settings.py
Expand Up @@ -91,6 +91,11 @@ class ResConfigSettings(models.TransientModel):
invoice_is_print = fields.Boolean(string='Print', related='company_id.invoice_is_print', readonly=False)
invoice_is_email = fields.Boolean(string='Send Email', related='company_id.invoice_is_email', readonly=False)
incoterm_id = fields.Many2one('account.incoterms', string='Default incoterm', related='company_id.incoterm_id', help='International Commercial Terms are a series of predefined commercial terms used in international transactions.', readonly=False)
invoice_terms = fields.Text(related='company_id.invoice_terms', string="Terms & Conditions", readonly=False)
use_invoice_terms = fields.Boolean(
string='Default Terms & Conditions',
oldname='default_use_sale_note',
config_parameter='account.use_invoice_terms')

@api.multi
def set_values(self):
Expand Down
17 changes: 17 additions & 0 deletions addons/account/views/res_config_settings_views.xml
Expand Up @@ -486,6 +486,23 @@
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="use_invoice_terms"/>
</div>
<div class="o_setting_right_pane">
<label for="use_invoice_terms"/>
<span class="fa fa-lg fa-building-o" title="Values set here are company-specific." aria-label="Values set here are company-specific." groups="base.group_multi_company" role="img"/>
<div class="text-muted">
Show standard terms &amp; conditions on invoices/orders
</div>
<div class="content-group" attrs="{'invisible': [('use_invoice_terms','=',False)]}">
<div class="mt16">
<field name="invoice_terms" placeholder="Insert your terms &amp; conditions here..."/>
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="group_warning_account"/>
Expand Down
8 changes: 1 addition & 7 deletions addons/sale/models/account_invoice.py
Expand Up @@ -11,13 +11,7 @@ class AccountInvoice(models.Model):
def _get_default_team(self):
return self.env['crm.team']._get_default_team_id()

def _default_comment(self):
invoice_type = self.env.context.get('type', 'out_invoice')
if invoice_type == 'out_invoice' and self.env['ir.config_parameter'].sudo().get_param('sale.use_sale_note'):
return self.env.user.company_id.sale_note

team_id = fields.Many2one('crm.team', string='Sales Team', default=_get_default_team, oldname='section_id')
comment = fields.Text(default=_default_comment)
partner_shipping_id = fields.Many2one(
'res.partner',
string='Delivery Address',
Expand Down Expand Up @@ -48,7 +42,7 @@ def _onchange_delivery_address(self):
self.partner_shipping_id = addr and addr.get('delivery')
if self.env.context.get('type', 'out_invoice') == 'out_invoice':
company = self.company_id or self.env.user.company_id
self.comment = company.with_context(lang=self.partner_id.lang).sale_note
self.comment = company.with_context(lang=self.partner_id.lang).invoice_terms

@api.multi
def action_invoice_open(self):
Expand Down
1 change: 0 additions & 1 deletion addons/sale/models/res_company.py
Expand Up @@ -7,7 +7,6 @@
class ResCompany(models.Model):
_inherit = "res.company"

sale_note = fields.Text(string='Default Terms and Conditions', translate=True)
portal_confirmation_sign = fields.Boolean(string='Online Signature')
portal_confirmation_pay = fields.Boolean(string='Online Payment')
quotation_validity_days = fields.Integer(default=30, string="Default Quotation Validity (Days)")
Expand Down
5 changes: 0 additions & 5 deletions addons/sale/models/res_config_settings.py
Expand Up @@ -7,11 +7,6 @@
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'

sale_note = fields.Text(related='company_id.sale_note', string="Terms & Conditions", readonly=False)
use_sale_note = fields.Boolean(
string='Default Terms & Conditions',
oldname='default_use_sale_note',
config_parameter='sale.use_sale_note')
group_discount_per_so_line = fields.Boolean("Discounts", implied_group='sale.group_discount_per_so_line')
module_sale_margin = fields.Boolean("Margins")
quotation_validity_days = fields.Integer(related='company_id.quotation_validity_days', string="Default Quotation Validity (Days)", readonly=False)
Expand Down
6 changes: 3 additions & 3 deletions addons/sale/models/sale.py
Expand Up @@ -101,7 +101,7 @@ def get_empty_list_help(self, help):

@api.model
def _default_note(self):
return self.env['ir.config_parameter'].sudo().get_param('sale.use_sale_note') and self.env.user.company_id.sale_note or ''
return self.env['ir.config_parameter'].sudo().get_param('account.use_invoice_terms') and self.env.user.company_id.invoice_terms or ''

@api.model
def _get_default_team(self):
Expand Down Expand Up @@ -306,8 +306,8 @@ def onchange_partner_id(self):
'partner_shipping_id': addr['delivery'],
'user_id': self.partner_id.user_id.id or self.env.uid
}
if self.env['ir.config_parameter'].sudo().get_param('sale.use_sale_note') and self.env.user.company_id.sale_note:
values['note'] = self.with_context(lang=self.partner_id.lang).env.user.company_id.sale_note
if self.env['ir.config_parameter'].sudo().get_param('account.use_invoice_terms') and self.env.user.company_id.invoice_terms:
values['note'] = self.with_context(lang=self.partner_id.lang).env.user.company_id.invoice_terms

# Use team of saleman before to fallback on team of partner.
values['team_id'] = self.partner_id.user_id and self.partner_id.user_id.sale_team_id.id or self.partner_id.team_id.id
Expand Down
17 changes: 0 additions & 17 deletions addons/sale/views/res_config_settings_views.xml
Expand Up @@ -177,23 +177,6 @@
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="use_sale_note"/>
</div>
<div class="o_setting_right_pane">
<label for="use_sale_note"/>
<span class="fa fa-lg fa-building-o" title="Values set here are company-specific." aria-label="Values set here are company-specific." groups="base.group_multi_company" role="img"/>
<div class="text-muted">
Show standard terms &amp; conditions on orders
</div>
<div class="content-group" attrs="{'invisible': [('use_sale_note','=',False)]}">
<div class="mt16">
<field name="sale_note" placeholder="Insert your terms &amp; conditions here..."/>
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="use_quotation_validity_days"/>
Expand Down
2 changes: 1 addition & 1 deletion addons/website_sale/views/templates.xml
Expand Up @@ -1695,7 +1695,7 @@
<div class="container">
<div class="row">
<div class="col-lg-12 mb16 mt16">
<p style='white-space:pre' t-esc="website.company_id.sale_note"/>
<p style='white-space:pre' t-esc="website.company_id.invoice_terms"/>
</div>
</div>
</div>
Expand Down