add charger doc

This commit is contained in:
guohuadeng
2018-08-06 17:22:59 +08:00
parent 69325060cb
commit b8b423e93b
11 changed files with 275 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3
================
MRP BOM Location
================
This module adds the location field to the Bill of Materials and its
components. This may be useful to distinguish between different BoMs for the
same product or to highlight the preferred locations to fetch the
components from.
The location appears in the BOM Structure Report.
Usage
=====
To use this module, you need to:
#. Go to *Manufacturing > Bill of Materials*.
#. Pick or create one of them.
#. You will see a new field to fill called "Location".
#. One the structure report *BOM > Print > BOM Structure* location field is present
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/129/11.0
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/manufacture/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing 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
------------
* Lois Rilo <lois.rilo@eficent.com>
* Mykhailo Panarin <m.panarin@mobilunity.com>
Do not contact contributors directly about support or help with technical
issues.
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,5 @@
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models
from . import report

View File

@@ -0,0 +1,19 @@
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "MRP BOM Location",
"summary": "Adds location field to Bill of Materials and its components.",
"version": "11.0.1.0.0",
"category": "Manufacture",
"website": "https://github.com/OCA/manufacture",
"author": "Eficent, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"depends": [
"mrp",
],
"data": [
"views/mrp_view.xml",
"views/report_mrpbomstructure.xml",
],
}

View File

@@ -0,0 +1,39 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_bom_location
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: mrp_bom_location
#: model:ir.model,name:mrp_bom_location.model_mrp_bom
msgid "Bill of Material"
msgstr ""
#. module: mrp_bom_location
#: model:ir.model.fields,field_description:mrp_bom_location.field_mrp_bom_line_location_id
#: model:ir.model.fields,field_description:mrp_bom_location.field_mrp_bom_location_id
#: model:ir.ui.view,arch_db:mrp_bom_location.report_mrpbomstructure_location
#: model:ir.ui.view,arch_db:mrp_bom_location.view_mrp_bom_filter
#: model:ir.ui.view,arch_db:mrp_bom_location.view_mrp_bom_line_filter
msgid "Location"
msgstr ""
#. module: mrp_bom_location
#: model:ir.model,name:mrp_bom_location.model_mrp_bom_line
msgid "mrp.bom.line"
msgstr ""
#. module: mrp_bom_location
#: model:ir.model,name:mrp_bom_location.model_report_mrp_mrp_bom_structure_report
msgid "report.mrp.mrp_bom_structure_report"
msgstr ""

View File

@@ -0,0 +1,4 @@
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import mrp_bom

View File

@@ -0,0 +1,29 @@
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class MrpBom(models.Model):
_inherit = "mrp.bom"
location_id = fields.Many2one(
string='Location',
comodel_name='stock.location',
)
@api.onchange('picking_type_id')
def _onchange_picking_type_id(self):
if (self.picking_type_id and
self.picking_type_id.default_location_src_id):
self.location_id = self.picking_type_id.default_location_src_id
class MrpBomLine(models.Model):
_inherit = "mrp.bom.line"
location_id = fields.Many2one(
related='bom_id.location_id',
readonly=True,
store=True,
)

View File

@@ -0,0 +1,4 @@
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import bom_structure

View File

@@ -0,0 +1,16 @@
# © 2017 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import api, models
class BomStructureReport(models.AbstractModel):
_inherit = 'report.mrp.mrp_bom_structure_report'
@api.model
def _get_child_vals(self, record, level, qty, uom):
res = super(BomStructureReport, self)._get_child_vals(
record, level, qty, uom)
res['location_name'] = record.location_id.complete_name or ''
return res

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 Eficent Business and IT Consulting Services S.L.
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0) -->
<odoo>
<record id="mrp_bom_form_view" model="ir.ui.view">
<field name="name">mrp.bom.form - mrp_bom_location</field>
<field name="model">mrp.bom</field>
<field name="inherit_id" ref="mrp.mrp_bom_form_view"/>
<field name="arch" type="xml">
<field name="routing_id" position="before">
<field name="location_id"/>
</field>
<xpath expr="//field[@name='bom_line_ids']/tree/field[@name='product_qty']" position="after">
<field name="location_id"/>
</xpath>
</field>
</record>
<record id="mrp_bom_tree_view" model="ir.ui.view">
<field name="name">mrp.bom.tree - mrp_bom_location</field>
<field name="model">mrp.bom</field>
<field name="inherit_id" ref="mrp.mrp_bom_tree_view"/>
<field name="arch" type="xml">
<field name="product_id" position="after">
<field name="location_id"/>
</field>
</field>
</record>
<record id="view_mrp_bom_filter" model="ir.ui.view">
<field name="name">mrp.bom.select - mrp_bom_location</field>
<field name="model">mrp.bom</field>
<field name="inherit_id" ref="mrp.view_mrp_bom_filter"/>
<field name="arch" type="xml">
<field name="product_tmpl_id" position="after">
<field name="location_id" string="Location"/>
</field>
<group expand="0" position="inside">
<filter string="Location" context="{'group_by':'location_id'}"/>
</group>
</field>
</record>
<record id="mrp_bom_component_tree_view" model="ir.ui.view">
<field name="name">mrp.bom.component.tree - mrp_bom_location</field>
<field name="model">mrp.bom.line</field>
<field name="inherit_id" ref="mrp.mrp_bom_component_tree_view"/>
<field name="arch" type="xml">
<field name="product_id" position="before">
<field name="location_id"/>
</field>
</field>
</record>
<record id="view_mrp_bom_line_filter" model="ir.ui.view">
<field name="name">mrp.bom.line.select - mrp_bom_location</field>
<field name="model">mrp.bom.line</field>
<field name="inherit_id" ref="mrp.view_mrp_bom_line_filter"/>
<field name="arch" type="xml">
<field name="product_id" position="after">
<field name="location_id" string="Location"/>
</field>
<group expand="0" position="inside">
<filter string="Location" context="{'group_by':'location_id'}"/>
</group>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="report_mrpbomstructure_location"
inherit_id="mrp.mrp_bom_structure_report">
<xpath expr="//thead/tr" position="inside">
<th>Location</th>
</xpath>
<xpath expr="//tbody/t/tr[1]" position="inside">
<td>
<span t-field="o.location_id.complete_name"/>
</td>
</xpath>
<xpath expr="//tbody/t/tr[2]" position="inside">
<td>
<span t-esc="l['location_name']"/>
</td>
</xpath>
</template>
</odoo>