Initialize v18 branch

Rename *_usability modules to *_usability_akretion
This commit is contained in:
Alexis de Lattre
2024-12-24 10:11:21 +01:00
parent 9913924202
commit 13744fc404
264 changed files with 50 additions and 87 deletions

View File

@@ -0,0 +1,5 @@
from . import product
from . import pos_category
from . import pos_payment_method
from . import pos_order
from . import pos_session

View File

@@ -0,0 +1,28 @@
# Copyright 2017-2021 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class PosCategory(models.Model):
_inherit = 'pos.category'
product_count = fields.Integer(
'# Products', compute='_compute_product_count',
help="The number of products under this point of sale category "
"(children categories included)")
# inspired by the code of odoo/addons/product/models/product_category.py
def _compute_product_count(self):
read_group_res = self.env['product.template'].read_group(
[('pos_categ_id', 'child_of', self.ids)],
['pos_categ_id'], ['pos_categ_id'])
group_data = dict(
(data['pos_categ_id'][0], data['pos_categ_id_count']) for data
in read_group_res)
for pos_categ in self:
product_count = 0
for sub_categ_id in pos_categ.search([('id', 'child_of', pos_categ.ids)]).ids:
product_count += group_data.get(sub_categ_id, 0)
pos_categ.product_count = product_count

View File

@@ -0,0 +1,23 @@
# Copyright 2024 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class PosOrder(models.Model):
_inherit = 'pos.order'
# field displayed in pos.order list view
payments_char = fields.Char(
string="Payment Methods", compute="_compute_payments_char", store=True)
@api.depends('payment_ids')
def _compute_payments_char(self):
for order in self:
payments = set()
for pay in order.payment_ids:
if pay.payment_method_id.name:
# unfortunately, 'name' of pos.payment.method is translate=True
payments.add(pay.payment_method_id.name)
order.payments_char = ', '.join(payments)

View File

@@ -0,0 +1,16 @@
# Copyright 2021 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class PosPaymentMethod(models.Model):
_inherit = 'pos.payment.method'
_check_company_auto = True
_order = 'sequence, id'
outstanding_account_id = fields.Many2one(check_company=True)
receivable_account_id = fields.Many2one(check_company=True)
journal_id = fields.Many2one(check_company=True)
sequence = fields.Integer(default=10)

View File

@@ -0,0 +1,14 @@
# Copyright 2023 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models
class PosSession(models.Model):
_inherit = 'pos.session'
def _loader_params_pos_payment_method(self):
res = super()._loader_params_pos_payment_method()
res['search_params']['order'] = "sequence, id"
return res

View File

@@ -0,0 +1,13 @@
# Copyright 2017-2021 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class ProductTemplate(models.Model):
_inherit = 'product.template'
available_in_pos = fields.Boolean(tracking=True, default=True)
to_weight = fields.Boolean(tracking=True)
pos_categ_id = fields.Many2one(tracking=True)