mirror of
https://github.com/OCA/stock-logistics-reporting.git
synced 2025-02-16 17:13:21 +02:00
[ADD] stock_picking_comment_template
This commit is contained in:
4
stock_picking_comment_template/models/__init__.py
Normal file
4
stock_picking_comment_template/models/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import stock_picking
|
||||
from . import res_partner
|
||||
13
stock_picking_comment_template/models/res_partner.py
Normal file
13
stock_picking_comment_template/models/res_partner.py
Normal file
@@ -0,0 +1,13 @@
|
||||
# Copyright 2019 C2i Change 2 improve - Eduardo Magdalena <emagdalena@c2i.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ResPartner(models.Model):
|
||||
_inherit = "res.partner"
|
||||
|
||||
comment_template_id = fields.Many2one(
|
||||
comodel_name='base.comment.template',
|
||||
string='Conditions template',
|
||||
)
|
||||
37
stock_picking_comment_template/models/stock_picking.py
Normal file
37
stock_picking_comment_template/models/stock_picking.py
Normal file
@@ -0,0 +1,37 @@
|
||||
# Copyright 2019 C2i Change 2 improve - Eduardo Magdalena <emagdalena@c2i.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class StockPicking(models.Model):
|
||||
"""Add text comment"""
|
||||
|
||||
_inherit = "stock.picking"
|
||||
|
||||
comment_template1_id = fields.Many2one('base.comment.template',
|
||||
string='Top Comment Template')
|
||||
comment_template2_id = fields.Many2one('base.comment.template',
|
||||
string='Bottom Comment Template')
|
||||
note1 = fields.Html('Top Comment')
|
||||
note2 = fields.Html('Bottom Comment')
|
||||
|
||||
@api.onchange('comment_template1_id')
|
||||
def _set_note1(self):
|
||||
comment = self.comment_template1_id
|
||||
if comment:
|
||||
self.note1 = comment.get_value(self.partner_id.id)
|
||||
|
||||
@api.onchange('comment_template2_id')
|
||||
def _set_note2(self):
|
||||
comment = self.comment_template2_id
|
||||
if comment:
|
||||
self.note2 = comment.get_value(self.partner_id.id)
|
||||
|
||||
@api.onchange('partner_id')
|
||||
def _onchange_partner_id(self):
|
||||
comment_template = self.partner_id.comment_template_id
|
||||
if comment_template.position == 'before_lines':
|
||||
self.comment_template1_id = comment_template
|
||||
elif comment_template.position == 'after_lines':
|
||||
self.comment_template2_id = comment_template
|
||||
Reference in New Issue
Block a user