Merge pull request #182 from credativUK/9.0-stock_partner_lot

[ADD] New module stock_partner_lot
This commit is contained in:
Pedro M. Baeza
2016-08-24 10:18:31 +02:00
committed by GitHub
6 changed files with 138 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
.. 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
=======================================
Show lots on the partners that own them
=======================================
This module lets users view which lots have been transferred to each partner and
search accordingly.
Usage
=====
You need to enable and use the 'Manage consignee stocks (advanced)'
functionality, for example by assigning owner to stock moves or locations.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/153/9.0
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/stock-logistics-workflow/issues>`_. In case of trouble,
please check there if your issue has already been reported. If you spotted it
first, help us smashing it by providing a detailed and welcomed feedback.
Credits
=======
Images
------
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
Contributors
------------
* Ondřej Kuzník <ondrej.kuznik@credativ.co.uk>
Maintainer
----------
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
To contribute to this module, please visit https://odoo-community.org.

View File

@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import models

View File

@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# (c) 2016 credativ ltd. - Ondřej Kuzník
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
{
'name': 'Owner Lot Visibility',
'summary': 'Show lots on the partners that own them',
'version': '9.0.1.0.0',
'category': 'Generic Modules/Inventory Control',
'author': 'credativ ltd., '
'Odoo Community Association (OCA)',
'license': 'AGPL-3',
'depends': [
'stock',
],
'data': [
'views/res_partner_view.xml',
],
}

View File

@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import res_partner

View File

@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
from openerp import api, fields, models
class ResPartner(models.Model):
_inherit = 'res.partner'
quant_ids = fields.One2many('stock.quant', 'owner_id',
string='Owned products')
quant_count = fields.Integer('Owned Products',
compute='_compute_quant_count')
@api.multi
def _compute_quant_count(self):
for partner in self:
partner.quant_count = len(partner.quant_ids)

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="ir.actions.act_window" id="owned_quants">
<field name="name">Stock</field>
<field name="res_model">stock.quant</field>
<field name="context">{'search_default_locationgroup':1}</field>
<field name="domain">[('owner_id', '=', active_id)]</field>
</record>
<record id="view_res_partner_lots" model="ir.ui.view">
<field name="name">res.partner.type.form.inherit</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="groups_id" eval="[(4, ref('stock.group_stock_user'))]"/>
<field name="arch" type="xml">
<div name="button_box" position="inside">
<button class="oe_stat_button o_res_partner_tip_opp" type="action"
attrs="{'invisible': [('quant_count', '=', 0)]}"
name="%(owned_quants)d"
icon="fa-building-o">
<field string="Owned Products" name="quant_count" widget="statinfo"/>
</button>
</div>
</field>
</record>
<record id="view_res_partner_lots_filter" model="ir.ui.view">
<field name="name">res.partner.select</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_res_partner_filter"/>
<field name="arch" type="xml">
<xpath expr="//search" position="inside">
<field name="quant_ids" string="Product" domain="[('quant_ids.product_id', 'ilike', self)]"/>
<field name="quant_ids" string="Lot name" domain="[('quant_ids.lot_id', 'ilike', self)]"/>
</xpath>
</field>
</record>
</data>
</openerp>