Initial commit: Sale packages

This commit is contained in:
Ernad Husremovic 2025-08-29 15:20:49 +02:00
commit 14e3d26998
6469 changed files with 2479670 additions and 0 deletions

View file

@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import product_template
from . import res_company
from . import sale_order
from . import sale_order_line
from . import sale_order_option
from . import sale_order_template
from . import sale_order_template_line
from . import sale_order_template_option

View file

@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models
from odoo.tools.translate import html_translate
class ProductTemplate(models.Model):
_inherit = "product.template"
quotation_only_description = fields.Html(
string="Quotation Only Description",
translate=html_translate,
sanitize_attributes=False,
sanitize_overridable=True,
help="The quotation description (not used on eCommerce)")
quotation_description = fields.Html(
string="Quotation Description",
compute='_compute_quotation_description',
sanitize_attributes=False,
sanitize_overridable=True,
help="This field uses the Quotation Only Description if it is defined, "
"otherwise it will try to read the eCommerce Description.")
def _compute_quotation_description(self):
for template in self:
if template.quotation_only_description:
template.quotation_description = template.quotation_only_description
elif hasattr(template, 'website_description') and template.website_description:
# Defined in website_sale
template.quotation_description = template.website_description
else:
template.quotation_description = ''

View file

@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models, api
class ResCompany(models.Model):
_inherit = 'res.company'
@api.model
def _set_default_sale_order_template_id_if_empty(self):
template = self.env.ref('sale_quotation_builder.sale_order_template_default', raise_if_not_found=False)
if not template:
return
companies = self.sudo().search([])
for company in companies:
company.sale_order_template_id = company.sale_order_template_id or template

View file

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
from odoo.tools.translate import html_translate
class SaleOrder(models.Model):
_inherit = 'sale.order'
website_description = fields.Html(
string="Website Description",
compute='_compute_website_description',
store=True, readonly=False, precompute=True,
sanitize_overridable=True,
sanitize_attributes=False, translate=html_translate, sanitize_form=False)
@api.depends('partner_id', 'sale_order_template_id')
def _compute_website_description(self):
orders_with_template = self.filtered('sale_order_template_id')
(self - orders_with_template).website_description = False
for order in orders_with_template:
order.website_description = order.sale_order_template_id.with_context(
lang=order.partner_id.lang
).website_description

View file

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
from odoo.tools.translate import html_translate
class SaleOrderLine(models.Model):
_inherit = "sale.order.line"
website_description = fields.Html(
string="Website Description",
compute='_compute_website_description',
store=True, readonly=False, precompute=True,
sanitize_overridable=True,
translate=html_translate,
sanitize_attributes=False)
@api.depends('product_id')
def _compute_website_description(self):
for line in self:
if not line.product_id:
continue
line.website_description = line.product_id.with_context(
lang=line.order_partner_id.lang
).quotation_description

View file

@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
from odoo.tools.translate import html_translate
class SaleOrderOption(models.Model):
_inherit = "sale.order.option"
website_description = fields.Html(
string="Website Description",
compute='_compute_website_description',
store=True, readonly=False, precompute=True,
sanitize_overridable=True,
sanitize_attributes=False, translate=html_translate)
@api.depends('product_id')
def _compute_website_description(self):
for option in self:
if not option.product_id:
continue
product = option.product_id.with_context(lang=option.order_id.partner_id.lang)
option.website_description = product.quotation_description
def _get_values_to_add_to_order(self):
values = super()._get_values_to_add_to_order()
values.update(website_description=self.website_description)
return values

View file

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models
from odoo.tools.translate import html_translate
class SaleOrderTemplate(models.Model):
_inherit = 'sale.order.template'
website_description = fields.Html(
string="Website Description",
translate=html_translate,
sanitize_overridable=True,
sanitize_attributes=False,
sanitize_form=False)
def action_open_template(self):
self.ensure_one()
return {
'type': 'ir.actions.act_url',
'target': 'self',
'url': '/@/sale_quotation_builder/template/%d' % self.id
}

View file

@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
from odoo.tools.translate import html_translate
class SaleOrderTemplateLine(models.Model):
_inherit = 'sale.order.template.line'
# FIXME ANVFE why are the sanitize_* attributes different between this field
# and the one on option lines, doesn't make any sense ???
website_description = fields.Html(
string="Website Description",
compute='_compute_website_description',
store=True, readonly=False,
translate=html_translate,
sanitize_overridable=True,
sanitize_form=False)
@api.depends('product_id')
def _compute_website_description(self):
for line in self:
if not line.product_id:
continue
line.website_description = line.product_id.quotation_description
#=== BUSINESS METHODS ===#
def _prepare_order_line_values(self):
res = super()._prepare_order_line_values()
res['website_description'] = self.website_description
return res

View file

@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
from odoo.tools.translate import html_translate
class SaleOrderTemplateOption(models.Model):
_inherit = 'sale.order.template.option'
website_description = fields.Html(
string="Website Description",
compute='_compute_website_description',
store=True, readonly=False,
translate=html_translate,
sanitize_overridable=True,
sanitize_attributes=False)
@api.depends('product_id')
def _compute_website_description(self):
for option in self:
if not option.product_id:
continue
option.website_description = option.product_id.quotation_description
#=== BUSINESS METHODS ===#
def _prepare_option_line_values(self):
res = super()._prepare_option_line_values()
res['website_description'] = self.website_description
return res