Add purchase buyer module
This commit is contained in:
31
purchase_order_buyer/README.rst
Normal file
31
purchase_order_buyer/README.rst
Normal file
@@ -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 buy default the user_id of the supplier and fallback to current user.
|
||||||
|
|
||||||
|
Credits
|
||||||
|
=======
|
||||||
|
|
||||||
|
|
||||||
|
Contributors
|
||||||
|
------------
|
||||||
|
|
||||||
|
* Raphaël Reverdy <raphael.reverdy@akretion.com>
|
||||||
|
|
||||||
|
Maintainer
|
||||||
|
----------
|
||||||
|
|
||||||
|
Akretion
|
||||||
2
purchase_order_buyer/__init__.py
Normal file
2
purchase_order_buyer/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from . import models
|
||||||
19
purchase_order_buyer/__manifest__.py
Normal file
19
purchase_order_buyer/__manifest__.py
Normal file
@@ -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,
|
||||||
|
}
|
||||||
3
purchase_order_buyer/models/__init__.py
Normal file
3
purchase_order_buyer/models/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from . import purchase_order
|
||||||
28
purchase_order_buyer/models/purchase_order.py
Normal file
28
purchase_order_buyer/models/purchase_order.py
Normal file
@@ -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,
|
||||||
|
})
|
||||||
BIN
purchase_order_buyer/static/description/icon.png
Normal file
BIN
purchase_order_buyer/static/description/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.5 KiB |
26
purchase_order_buyer/views/purchase_order.xml
Normal file
26
purchase_order_buyer/views/purchase_order.xml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<record id="purchase_order_tree" model="ir.ui.view">
|
||||||
|
<field name="name">purchase.order.tree</field>
|
||||||
|
<field name="model">purchase.order</field>
|
||||||
|
<field name="inherit_id" ref="purchase.purchase_order_tree"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="partner_id" position="after">
|
||||||
|
<field name="user_id" />
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="purchase_order_form" model="ir.ui.view">
|
||||||
|
<field name="name">purchase.order.form</field>
|
||||||
|
<field name="model">purchase.order</field>
|
||||||
|
<field name="inherit_id" ref="purchase.purchase_order_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="partner_id" position="after">
|
||||||
|
<field name="user_id" />
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
Reference in New Issue
Block a user