Начальное наполнение
This commit is contained in:
parent
20e1f9b5b5
commit
584f052228
4
__init__.py
Normal file
4
__init__.py
Normal file
@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import models
|
14
__manifest__.py
Normal file
14
__manifest__.py
Normal file
@ -0,0 +1,14 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
{
|
||||
'name': "Sales - Service",
|
||||
'summary': "Interaction between Sales and services apps (project and planning)",
|
||||
'description': """
|
||||
Allows to display sale information in the SOL services apps
|
||||
===========================================================
|
||||
Additional information is displayed in the name of the SOL when it is used in services apps (project and planning).
|
||||
""",
|
||||
'category': 'Hidden',
|
||||
'depends': ['sale_management'],
|
||||
'license': 'LGPL-3',
|
||||
}
|
28
i18n/ru.po
Normal file
28
i18n/ru.po
Normal file
@ -0,0 +1,28 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * sale_service
|
||||
#
|
||||
# Translators:
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 17.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2023-10-26 21:55+0000\n"
|
||||
"PO-Revision-Date: 2024-01-30 15:14+0400\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: Russian (https://app.transifex.com/odoo/teams/41243/ru/)\n"
|
||||
"Language: ru\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n"
|
||||
|
||||
#. module: sale_service
|
||||
#: model:ir.model.fields,field_description:sale_service.field_sale_order_line__is_service
|
||||
msgid "Is a Service"
|
||||
msgstr "Является услугой"
|
||||
|
||||
#. module: sale_service
|
||||
#: model:ir.model,name:sale_service.model_sale_order_line
|
||||
msgid "Sales Order Line"
|
||||
msgstr "Позиция заказа на продажу"
|
26
i18n/sale_service.pot
Normal file
26
i18n/sale_service.pot
Normal file
@ -0,0 +1,26 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * sale_service
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 17.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2023-10-26 21:55+0000\n"
|
||||
"PO-Revision-Date: 2023-10-26 21:55+0000\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: sale_service
|
||||
#: model:ir.model.fields,field_description:sale_service.field_sale_order_line__is_service
|
||||
msgid "Is a Service"
|
||||
msgstr ""
|
||||
|
||||
#. module: sale_service
|
||||
#: model:ir.model,name:sale_service.model_sale_order_line
|
||||
msgid "Sales Order Line"
|
||||
msgstr ""
|
4
models/__init__.py
Normal file
4
models/__init__.py
Normal file
@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import sale_order_line
|
53
models/sale_order_line.py
Normal file
53
models/sale_order_line.py
Normal file
@ -0,0 +1,53 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from itertools import groupby
|
||||
|
||||
from odoo import api, fields, models
|
||||
from odoo.tools import format_amount
|
||||
from odoo.tools.sql import column_exists, create_column
|
||||
|
||||
|
||||
class SaleOrderLine(models.Model):
|
||||
_inherit = "sale.order.line"
|
||||
|
||||
# used to know if generate a task and/or a project, depending on the product settings
|
||||
is_service = fields.Boolean("Is a Service", compute='_compute_is_service', store=True, compute_sudo=True)
|
||||
|
||||
@api.depends('product_id.type')
|
||||
def _compute_is_service(self):
|
||||
for so_line in self:
|
||||
so_line.is_service = so_line.product_id.type == 'service'
|
||||
|
||||
def _auto_init(self):
|
||||
"""
|
||||
Create column to stop ORM from computing it himself (too slow)
|
||||
"""
|
||||
if not column_exists(self.env.cr, 'sale_order_line', 'is_service'):
|
||||
create_column(self.env.cr, 'sale_order_line', 'is_service', 'bool')
|
||||
self.env.cr.execute("""
|
||||
UPDATE sale_order_line line
|
||||
SET is_service = (pt.type = 'service')
|
||||
FROM product_product pp
|
||||
LEFT JOIN product_template pt ON pt.id = pp.product_tmpl_id
|
||||
WHERE pp.id = line.product_id
|
||||
""")
|
||||
return super()._auto_init()
|
||||
|
||||
def _additional_name_per_id(self):
|
||||
name_per_id = super()._additional_name_per_id() if not self.env.context.get('hide_partner_ref') else {}
|
||||
if not self.env.context.get('with_price_unit'):
|
||||
return name_per_id
|
||||
|
||||
sols_list = [list(sols) for dummy, sols in groupby(self, lambda sol: (sol.order_id, sol.product_id))]
|
||||
for sols in sols_list:
|
||||
if len(sols) <= 1 or not all(sol.is_service for sol in sols):
|
||||
continue
|
||||
for line in sols:
|
||||
additional_name = name_per_id.get(line.id)
|
||||
name = format_amount(self.env, line.price_unit, line.currency_id)
|
||||
if additional_name:
|
||||
name += f' {additional_name}'
|
||||
name_per_id[line.id] = f'- {name}'
|
||||
|
||||
return name_per_id
|
Loading…
x
Reference in New Issue
Block a user