mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-18 16:12:08 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
|
|
@ -0,0 +1 @@
|
|||
from . import res_partner
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
# Copyright 2018 Creu Blanca
|
||||
# Copyright 2020 ForgeFlow S.L.
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
import json
|
||||
|
||||
from odoo import _, models
|
||||
from odoo.tools.safe_eval import safe_eval
|
||||
|
||||
|
||||
class ResPartner(models.Model):
|
||||
_inherit = "res.partner"
|
||||
|
||||
def find_res_partner_by_ref_using_barcode(self, barcode):
|
||||
partner = self.search([("ref", "=", barcode)], limit=1)
|
||||
if not partner:
|
||||
xmlid = "barcode_action.res_partner_find"
|
||||
action = self.env["ir.actions.act_window"]._for_xml_id(xmlid)
|
||||
context = safe_eval(action["context"])
|
||||
context.update(
|
||||
{
|
||||
"default_state": "warning",
|
||||
"default_status": _(
|
||||
"Partner with Internal Reference " "%s cannot be found"
|
||||
)
|
||||
% barcode,
|
||||
}
|
||||
)
|
||||
action["context"] = json.dumps(context)
|
||||
return action
|
||||
xmlid = "base.action_partner_form"
|
||||
action = self.env["ir.actions.act_window"]._for_xml_id(xmlid)
|
||||
res = self.env.ref("base.view_partner_form", False)
|
||||
action["views"] = [(res and res.id or False, "form")]
|
||||
action["res_id"] = partner.id
|
||||
return action
|
||||
Loading…
Add table
Add a link
Reference in a new issue