diff --git a/purchase_order_buyer/README.rst b/purchase_order_buyer/README.rst new file mode 100644 index 0000000..6171bf7 --- /dev/null +++ b/purchase_order_buyer/README.rst @@ -0,0 +1,31 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +==================== +Purchase Order Buyer +==================== + +Adds a buyer on the Purchase Order. (Like a vendor on sales). + +A prefered buyer can be set on the supplier. + +Usage +===== + +To use this module, you need to go to Purchase > Purchase Order: there a new field "Buyer" +It will use by default the user_id of the supplier and fallback to current user. + +Credits +======= + + +Contributors +------------ + +* Raphaƫl Reverdy + +Maintainer +---------- + +Akretion diff --git a/purchase_order_buyer/__init__.py b/purchase_order_buyer/__init__.py new file mode 100644 index 0000000..a0fdc10 --- /dev/null +++ b/purchase_order_buyer/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import models diff --git a/purchase_order_buyer/__manifest__.py b/purchase_order_buyer/__manifest__.py new file mode 100644 index 0000000..4104d0c --- /dev/null +++ b/purchase_order_buyer/__manifest__.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Akretion (https://akretion.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + "name": "Purchase Order Buyer", + "summary": "Add a buyer (user) on POs", + "version": "10.0.1.1.0", + "author": "Akretion", + "website": "https://github.com/akretion/odoo-usability", + "category": "Purchases", + "depends": ["purchase"], + "data": [ + 'views/purchase_order.xml', + ], + "license": "AGPL-3", + "installable": True, + "application": False, +} diff --git a/purchase_order_buyer/models/__init__.py b/purchase_order_buyer/models/__init__.py new file mode 100644 index 0000000..16dca48 --- /dev/null +++ b/purchase_order_buyer/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import purchase_order diff --git a/purchase_order_buyer/models/purchase_order.py b/purchase_order_buyer/models/purchase_order.py new file mode 100644 index 0000000..1ee8647 --- /dev/null +++ b/purchase_order_buyer/models/purchase_order.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Raphael Reverdy https://akretion.com +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class PurchaseOrder(models.Model): + _inherit = 'purchase.order' + + user_id = fields.Many2one( + 'res.users', + string='Buyer', index=True, + track_visibility='onchange', + default=lambda self: self.env.user) + + @api.multi + @api.onchange('partner_id') + def onchange_partner_id(self): + """Update the user_id (buyer)""" + for rec in self: + if rec.partner_id and rec.partner_id.user_id: + user_id = rec.partner_id.user_id.id + else: + user_id = self.env.user + return rec.update({ + 'user_id': user_id, + }) diff --git a/purchase_order_buyer/static/description/icon.png b/purchase_order_buyer/static/description/icon.png new file mode 100644 index 0000000..c91da79 Binary files /dev/null and b/purchase_order_buyer/static/description/icon.png differ diff --git a/purchase_order_buyer/views/purchase_order.xml b/purchase_order_buyer/views/purchase_order.xml new file mode 100644 index 0000000..689e944 --- /dev/null +++ b/purchase_order_buyer/views/purchase_order.xml @@ -0,0 +1,26 @@ + + + + + purchase.order.tree + purchase.order + + + + + + + + + + purchase.order.form + purchase.order + + + + + + + + +