añadidos tax y pos_category por defecto by category

This commit is contained in:
santiky 2022-03-24 11:04:28 +01:00
parent 4abeea64a5
commit a26a8e2c32
Signed by: snt
GPG key ID: A9FD34930EADBE71
18 changed files with 297 additions and 0 deletions

View file

@ -0,0 +1 @@
from . import models

View file

@ -0,0 +1,20 @@
# Copyright 2021 Criptomart
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Product Category Default PoS Category',
'version': '12.0.1.0.0',
'author': "Criptomart",
'website': 'https://github.com/criptomart/obook',
'license': 'AGPL-3',
'category': 'Product',
'depends': [
'product',
'point_of_sale'
],
'data': [
'views/product_category.xml',
'views/res_config_settings_views.xml',
],
'installable': True,
}

View file

@ -0,0 +1,4 @@
from . import res_company
from . import res_config_settings
from . import product_product
from . import product_category

View file

@ -0,0 +1,15 @@
# Copyright 2018 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class ProductCategory(models.Model):
_inherit = 'product.category'
pos_categ_id = fields.Many2one(
comodel_name="pos.category", string="Categoría en el Punto de Venta",
help="Configura los productos nuevos de ésta categoría, a la categoría del punto de venta definido aquí.",
)

View file

@ -0,0 +1,40 @@
# Copyright 2021 Criptomart
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
#import logging
from odoo import _, api, fields, models
#_logger = logging.getLogger(__name__)
class ProductProduct(models.Model):
_inherit = 'product.product'
@api.model
def create(self, vals):
category = self.env['product.category']
categ_id = vals.get("categ_id")
template_id = vals.get("product_tmpl_id")
if categ_id:
category = category.browse(categ_id)
vals['pos_categ_id'] = self.get_category_pos_category(category)
vals['available_in_pos'] = True
elif template_id:
template = self.env["product.template"].browse(template_id)
category = template.categ_id
template.pos_categ_id = self.get_category_pos_category(category)
if template.pos_categ_id:
template.available_in_pos = True
return super().create(vals)
@api.model
def get_category_pos_category(self, category=False):
cat = category
if self.env.user.company_id.use_parent_categories_to_determine_pos_categ:
while not cat.pos_categ_id and cat.parent_id:
cat = cat.parent_id
return cat.pos_categ_id

View file

@ -0,0 +1,13 @@
# Copyright 2021 Criptomart
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class Company(models.Model):
_inherit = 'res.company'
use_parent_categories_to_determine_pos_categ = fields.Boolean(
string="Use parent categories to determine the pos category",
help="Use parent categories to determine the pos category if the category has no settings for the PoS category.",
)

View file

@ -0,0 +1,13 @@
# Copyright 2021 Criptomart
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
use_parent_categories_to_determine_pos_categ = fields.Boolean(
related="company_id.use_parent_categories_to_determine_pos_categ",
readonly=False,
)

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="product_category_form_view" model="ir.ui.view">
<field name="name">product.category.form - product_category_pos_categ</field>
<field name="model">product.category</field>
<field name="inherit_id" ref="product.product_category_form_view"/>
<field name="arch" type="xml">
<field name="parent_id" position="after">
<field name="pos_categ_id" class="oe_inline" />
</field>
</field>
</record>
</odoo>

View file

@ -0,0 +1,26 @@
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit.product</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="product.res_config_settings_view_form" />
<field name="arch" type="xml">
<div id="product_general_settings" position="inside">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="use_parent_categories_to_determine_pos_categ" />
</div>
<div class="o_setting_right_pane">
<label for="use_parent_categories_to_determine_pos_categ"
string="Use parent categories to determine the PoS category" />
<div class="text-muted">
Use parent categories to determine the PoS category if the category
has no settings for the prefix.
</div>
</div>
</div>
</div>
</field>
</record>
</odoo>

View file

@ -0,0 +1 @@
from . import models

View file

@ -0,0 +1,20 @@
# Copyright 2021 Criptomart
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Product Category Tax',
'version': '12.0.1.0.0',
'author': "Criptomart",
'website': 'https://github.com/criptomart/obook',
'license': 'AGPL-3',
'category': 'Product',
'depends': [
'product',
'account'
],
'data': [
'views/product_category.xml',
'views/res_config_settings_views.xml',
],
'installable': True,
}

View file

@ -0,0 +1,4 @@
from . import res_company
from . import res_config_settings
from . import product_product
from . import product_category

View file

@ -0,0 +1,19 @@
# Copyright 2018 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class ProductCategory(models.Model):
_inherit = 'product.category'
sell_tax_id = fields.Many2one(
comodel_name="account.tax", string="Impuesto de venta del producto",
help="Configura los productos de ésta categoría al impuesto definido aquí.",
)
buy_tax_id = fields.Many2one(
comodel_name="account.tax", string="Impuesto de compra del producto",
help="Configura los productos de ésta categoría al impuesto definido aquí.",
)

View file

@ -0,0 +1,35 @@
# Copyright 2021 Criptomart
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import logging
from odoo import _, api, fields, models
_logger = logging.getLogger(__name__)
class ProductProduct(models.Model):
_inherit = 'product.product'
@api.model
def create(self, vals):
category = self.env['product.category']
categ_id = vals.get("categ_id")
template_id = vals.get("product_tmpl_id")
if categ_id:
category = category.browse(categ_id)
vals['taxes_id'] = category.sell_tax_id
vals['supplier_taxes_id'] = category.buy_tax_id
elif template_id:
template = self.env["product.template"].browse(template_id)
cat = template.categ_id
if self.env.user.company_id.use_parent_categories_to_determine_taxes:
while not cat.pos_categ_id and cat.parent_id:
cat = cat.parent_id
if cat:
template.taxes_id = cat.sell_tax_id
template.supplier_taxes_id = cat.buy_tax_id
return super(ProductProduct, self).create(vals)

View file

@ -0,0 +1,13 @@
# Copyright 2021 Criptomart
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class Company(models.Model):
_inherit = 'res.company'
use_parent_categories_to_determine_taxes = fields.Boolean(
string="Use parent categories to determine the taxes",
help="Use parent categories to determine the taxes if the category has no settings for the taxes.",
)

View file

@ -0,0 +1,13 @@
# Copyright 2021 Criptomart
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
use_parent_categories_to_determine_taxes = fields.Boolean(
related="company_id.use_parent_categories_to_determine_taxes",
readonly=False,
)

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="product_category_form_view" model="ir.ui.view">
<field name="name">product.category.form - product_category_tax</field>
<field name="model">product.category</field>
<field name="inherit_id" ref="product.product_category_form_view"/>
<field name="arch" type="xml">
<field name="parent_id" position="after">
<field name="sell_tax_id" class="oe_inline" widget="selection" domain="[('type_tax_use', '=', 'sale')]" />
<field name="buy_tax_id" class="oe_inline" widget="selection" domain="[('type_tax_use', '=', 'purchase')]" />
</field>
</field>
</record>
</odoo>

View file

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 Eficent Business and IT Consulting Services S.L.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit.product</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="product.res_config_settings_view_form" />
<field name="arch" type="xml">
<div id="product_general_settings" position="inside">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="use_parent_categories_to_determine_taxes" />
</div>
<div class="o_setting_right_pane">
<label for="use_parent_categories_to_determine_taxes"
string="Use parent categories to determine the taxes" />
<div class="text-muted">
Use parent categories to determine the taxes if the category
has no settings for the prefix.
</div>
</div>
</div>
</div>
</field>
</record>
</odoo>