← Back to team overview

openerp-community team mailing list archive

[Merge] lp:~lin-yu/openobject-addons/elico-7.0 into lp:~openerp-community/openobject-addons/elico-7.0

 

LIN Yu has proposed merging lp:~lin-yu/openobject-addons/elico-7.0 into lp:~openerp-community/openobject-addons/elico-7.0.

Requested reviews:
  LIN Yu (lin-yu)

For more details, see:
https://code.launchpad.net/~lin-yu/openobject-addons/elico-7.0/+merge/181687

[ADD] account_invoice_line, mrp_move_direct, purchase_price_list_item, purchase_po_price, purchase_control_supplier,

-- 
https://code.launchpad.net/~lin-yu/openobject-addons/elico-7.0/+merge/181687
Your team OpenERP Community is subscribed to branch lp:~openerp-community/openobject-addons/elico-7.0.
=== added directory 'account_invoice_line'
=== added file 'account_invoice_line/__init__.py'
--- account_invoice_line/__init__.py	1970-01-01 00:00:00 +0000
+++ account_invoice_line/__init__.py	2013-08-23 02:20:58 +0000
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
+#    Author: Andy Lu <andy.lu@xxxxxxxxxxxxxx>
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import account
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file

=== added file 'account_invoice_line/__openerp__.py'
--- account_invoice_line/__openerp__.py	1970-01-01 00:00:00 +0000
+++ account_invoice_line/__openerp__.py	2013-08-23 02:20:58 +0000
@@ -0,0 +1,51 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
+#    Author: LIN Yu <lin.yu@xxxxxxxxxxxxxx>
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+{
+    'name': 'Invoice Line',
+    'version': '1.1',
+    'category': 'Account',
+    'sequence': 19,
+    'summary': 'Invoice line',
+    'description': """
+Invoice Line
+==================================================
+* Add Account Invoice Line View
+* Add Account Invoice Type
+* Add Several New Fields to Invoice supplier_invoice_number, fapiao_date, partner_ref, reference_type
+    """,
+    'author': 'Elico Corp',
+    'website': 'http://www.elico-corp.com',
+    'images' : [],
+    'depends': ['account'],
+    'data': [
+        'account_view.xml',        
+        'security/ir.model.access.csv',
+    ],
+    'test': [],
+    'demo': [],
+    'installable': True,
+    'auto_install': False,
+    'application': False,
+}
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file

=== added file 'account_invoice_line/account.py'
--- account_invoice_line/account.py	1970-01-01 00:00:00 +0000
+++ account_invoice_line/account.py	2013-08-23 02:20:58 +0000
@@ -0,0 +1,106 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
+#    Author: Andy Lu <andy.lu@xxxxxxxxxxxxxx>
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import osv, fields
+from tools.translate import _
+import openerp.addons.decimal_precision as dp
+import time
+
+class account_invoice_type(osv.osv):
+    _name = "account.invoice.type"
+    _description = "Account Invoice Type"
+
+    _columns = {
+        'name': fields.char('Name',size=128, required=True, translate=True),
+    }
+
+account_invoice_type()
+
+class account_invoice(osv.osv):
+    _inherit = "account.invoice"
+
+    def _get_reference_type(self, cr, uid, context=None):
+        return [('none', _('Free Reference'))] #,
+    
+    _columns = {
+        'account_invoice_type': fields.many2one('account.invoice.type', 'Invoice Type'),
+        'supplier_invoice_number': fields.char('Supplier Inv Ref', size=64, help="The reference of this invoice as provided by the supplier."),
+        'fapiao_date': fields.date('V.A.T Date', ),
+        'partner_ref': fields.related('partner_id','ref',type='char', size=64, string='Partner Ref'),
+        'reference_type': fields.selection(_get_reference_type, 'Payment Reference',
+            required=True, readonly=True, states={'draft':[('readonly',False)]}),
+    }
+account_invoice()
+
+class account_invoice_line(osv.osv):
+    _inherit = "account.invoice.line"
+
+    def _amount_line_with_tax(self, cr, uid, ids, prop, arg, context=None):
+        res = {}
+        tax_obj = self.pool.get('account.tax')
+        cur_obj = self.pool.get('res.currency')
+        for line in self.browse(cr, uid, ids, context=context):
+            price = line.price_unit * (1-(line.discount or 0.0)/100.0)
+            taxes = tax_obj.compute_all(cr, uid, line.invoice_line_tax_id, price, line.quantity, product=line.product_id, partner=line.invoice_id.partner_id, force_excluded=True)
+            res[line.id] = taxes['total']
+            if line.invoice_id:
+                cur = line.invoice_id.currency_id
+                res[line.id] = cur_obj.round(cr, uid, cur, res[line.id])
+        return res
+    
+    _columns = {
+        'amount_subtotal': fields.function(_amount_line_with_tax, string='Amount (Inc. Tax)', type='float', digits_compute=dp.get_precision('Account')),
+        'partner_ref': fields.related(
+                    'partner_id', 'ref',
+                    type='char', size=64,relation='res.partner',
+                    string='Partner Ref',select=1),
+        'type': fields.related(
+                    'invoice_id', 'type',
+                    type='char', size=64,relation='account.invoice',
+                    string='Type'),
+        'number': fields.related(
+                    'invoice_id', 'number',
+                    type='char', size=64,relation='account.invoice',
+                    string='Number',select=1),
+        'supplier_invoice_number': fields.related(
+                    'invoice_id', 'supplier_invoice_number',
+                    type='char', size=64,relation='account.invoice',
+                    string='Supplier Inv Ref',select=1),
+        'date_invoice': fields.related(
+                    'invoice_id', 'date_invoice',
+                    type='date', relation='account.invoice',
+                    string='Date Invoice',select=1),
+        'fapiao_date': fields.related(
+                    'invoice_id', 'fapiao_date',
+                    type='date', relation='account.invoice',
+                    string='V.A.T Date',select=1),
+        'state': fields.related(
+                    'invoice_id', 'state',
+                    type='char', size=16,relation='account.invoice',
+                    string='State'),
+        'reference': fields.related(
+                    'invoice_id', 'reference',
+                    type='char', size=16,relation='account.invoice',
+                    string='Reference'),
+    }
+account_invoice_line()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'account_invoice_line/account_view.xml'
--- account_invoice_line/account_view.xml	1970-01-01 00:00:00 +0000
+++ account_invoice_line/account_view.xml	2013-08-23 02:20:58 +0000
@@ -0,0 +1,220 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+        
+      
+		<!-- Invoice Line by LY-->
+
+		<record id="account_invoice_line_tree" model="ir.ui.view">
+            <field name="name">account_invoice_line_tree</field>
+            <field name="model">account.invoice.line</field>
+            <field name="inherit_id" ref="account.view_invoice_line_tree"/>
+            <field name="arch" type="xml">
+            
+            	<xpath expr="/tree" position="attributes">
+            		<attribute name="create">0</attribute>
+            		<attribute name="delete">0</attribute>
+            	</xpath>  
+            	<xpath expr="/tree/field[@name='name']" position="before">
+            		<field name="partner_ref"/>
+            		<field name="partner_id"/>
+            		<field name="supplier_invoice_number"/>
+            		<field name="number"/>
+                    <field name="fapiao_date"/>
+            		<field name="date_invoice"/>
+            		<field name="invoice_id" invisible='1'/>
+            		<field name="origin"/>
+                </xpath>
+                <xpath expr="/tree/field[@name='quantity']" position="replace">
+            		<field name="product_id"/>
+            		<field name="quantity" sum="Quantity"/>
+                </xpath>
+                <xpath expr="//field[@name='price_subtotal']" position="replace">
+                	<field name="amount_subtotal" sum="Amount"/>
+					<field name="amount_subtotal" sum="Amount(Inc.Tax)"/>
+					<field name="state"/>
+					<field name="reference" string='Reference'/>
+		        </xpath>
+            </field>
+        </record>
+		<record id="account_invoice_line_search" model="ir.ui.view">
+            <field name="name">account.invoice.line.search.elico</field>
+            <field name="model">account.invoice.line</field>
+            <field name="arch" type="xml">
+            	<search string="Search Invoice">
+            		<field name="number" string="Number" filter_domain="['|','|',('number','ilike',self),('supplier_invoice_number','ilike',self),('origin','ilike',self)]"/>
+            		<field name="supplier_invoice_number" string="Supplier Invoice Number" />
+            		<field name="partner_id" string="Partner"/>
+            		<field name="partner_ref" string="Partner ref"/>
+            		<field name="product_id" string="Product" />
+            		<filter icon="terp-go-today" string="Draft" domain="[('state','=','draft')]" help="draft"/>
+            		<filter icon="terp-go-today" string="Open" domain="[('state','not in',('done','draft','cancel'))]" help="draft"/>
+            		<filter icon="terp-go-today" string="Paid" domain="[('state','=','done')]" help="Paid"/>
+            		<filter icon="terp-go-today" string="Cancel" domain="[('state','=','cancel')]" help="Cancel"/>
+                    <separator/>
+                    <filter icon="terp-go-today" string="Today" domain="[('date_invoice','&lt;=',time.strftime('%%Y-%%m-%%d 23:59:59')),('date_invoice','&gt;=',time.strftime('%%Y-%%m-%%d 00:00:00'))]" help="Orders processed Today or planned for Today"/>
+                    <group expand="0" string="Group By...">
+                    	<filter icon="terp-partner" string="Partner" domain="[]" context="{'group_by':'partner_id'}"/>
+                    	<filter icon="terp-product" string="Product" domain="[]" context="{'group_by':'product_id'}"/>
+                    	<filter icon="terp-invoice" string="Invoice" domain="[]" context="{'group_by':'invoice_id'}"/>
+                    	<filter icon="terp-state" string="State" domain="[]" context="{'group_by':'state'}"/>
+                    </group>
+                </search>
+            </field>
+        </record>
+		
+		<record id="action_supplier_invoice_line" model="ir.actions.act_window">
+            <field name="name">Invoice Line</field>
+            <field name="type">ir.actions.act_window</field>
+            <field name="res_model">account.invoice.line</field>
+            <field name="context">{}</field>
+            <field name="domain">[('type','=','in_invoice')]</field>
+            <field name="view_mode">tree</field>
+            <field name="view_id" ref="account.view_invoice_line_tree"/>
+            <field name="search_view_id" ref="account_invoice_line_search"/>
+            <field name="help" type="html">
+              <p class="oe_view_nocontent_create">
+                Click to check Invoice Line.
+              </p>
+            </field>
+        </record>
+		<menuitem id="suppler_invoice_line" name="Supplier Invoice Line" parent="account.menu_finance_payables" action="action_supplier_invoice_line" sequence="13"/>
+
+		
+		<record id="action_customer_invoice_line" model="ir.actions.act_window">
+            <field name="name">Invoice Line</field>
+            <field name="type">ir.actions.act_window</field>
+            <field name="res_model">account.invoice.line</field>
+            <field name="context">{}</field>
+            <field name="domain">[('type','=','out_invoice')]</field>
+            <field name="view_mode">tree</field>
+            <field name="view_id" ref="account.view_invoice_line_tree"/>
+            <field name="search_view_id" ref="account_invoice_line_search"/>
+            <field name="help" type="html">
+        
+              <p class="oe_view_nocontent_create">
+                Click to check Invoice Line.
+              </p>
+            </field>
+        </record>
+		<menuitem id="customer_invoice_line" name="Customer Invoice Line" parent="account.menu_finance_receivables" action="action_customer_invoice_line" sequence="13"/>
+
+
+        <!--
+        Account Invoice
+        -->
+        <record model="ir.ui.view" id="invoice_ait_tree">
+            <field name="name">account.invoice.ait.tree</field>
+            <field name="model">account.invoice</field>
+            <field name="inherit_id" ref="account.invoice_tree" />
+            <field name="arch" type="xml">
+                <xpath expr="//field[@name='partner_id']" position="before">
+                    <field name="partner_ref"/>
+                </xpath>
+                <xpath expr="//field[@name='partner_id']" position="after">
+                    <field name="supplier_invoice_number"/>
+                    <field name="fapiao_date"/>
+                </xpath>
+                <xpath expr="//field[@name='state']" position="before">
+                    <field name="account_invoice_type"/>
+                    <field name="reference"/>
+                    <field name="type" invisible="1"/>
+                </xpath>
+            </field>
+        </record>
+
+        <record model="ir.ui.view" id="invoice_supplier_ait_form">
+            <field name="name">account.invoice.supplier.ait.form</field>
+            <field name="model">account.invoice</field>
+            <field name="inherit_id" ref="account.invoice_supplier_form" />
+            <field name="arch" type="xml">
+                <xpath expr="//field[@name='supplier_invoice_number']" position="after">
+                    <field name="fapiao_date"/>
+                </xpath>            
+                <xpath expr="//field[@name='journal_id']" position="after">
+                    <field name="account_invoice_type"/>
+                </xpath>            
+                <xpath expr="//field[@name='price_subtotal']" position="after">
+                    <field name="amount_subtotal"/>
+                </xpath>
+            </field>
+        </record>
+        <record model="ir.ui.view" id="invoice_ait_form">
+            <field name="name">account.invoice.ait.form</field>
+            <field name="model">account.invoice</field>
+            <field name="inherit_id" ref="account.invoice_form" />
+            <field name="arch" type="xml">
+                <xpath expr="//field[@name='account_id']" position="after">
+                    <field name="supplier_invoice_number"/>
+                    <field name="fapiao_date"/>
+                </xpath>
+                <xpath expr="//field[@name='fiscal_position']" position="after">
+                    <field name="account_invoice_type"/>
+                </xpath>
+            </field>
+        </record>
+        <record model="ir.ui.view" id="view_account_invoice_ait_filter">
+            <field name="name">account.invoice.ait.select</field>
+            <field name="model">account.invoice</field>
+            <field name="inherit_id" ref="account.view_account_invoice_filter" />
+            <field name="arch" type="xml">
+                <xpath expr="//field[@name='user_id']" position="after">
+                    <field name="partner_ref"/>
+                    <field name="supplier_invoice_number"/>
+                    <field name="account_invoice_type"/>
+                    
+                    <filter string="Invoice" icon="terp-partner" domain="[('type','=','in_invoice')]"/>
+                    <filter string="Refund" icon="terp-partner" domain="[('type','=','in_refund')]"/>
+                    <separator/>
+                </xpath>
+                <xpath expr="//filter[@string='Journal']" position="after">
+                    <filter string="Tax Type" icon="terp-partner" domain="[]" context="{'group_by':'account_invoice_type'}"/>
+                    <filter string="Partner Ref" icon="terp-partner" domain="[]" context="{'group_by':'partner_ref'}"/>
+                    <filter string="Type" icon="terp-partner" domain="[]" context="{'group_by':'type'}"/>
+                </xpath>
+            </field>
+        </record>
+        
+
+        <!--
+        Account Invoice Tax Type
+        -->        
+        <record id="view_account_invoice_type" model="ir.ui.view">
+            <field name="name">account.invoice.type.view</field>
+            <field name="model">account.invoice.type</field>
+            <field name="type">tree</field>
+            <field name="arch" type="xml">
+                <tree string="invoice type" editable="top">
+                    <field name="name"/>
+                </tree>
+            </field>
+        </record>
+
+        <record id="action_account_invoice_type" model="ir.actions.act_window">
+            <field name="name">Account Invoice Type</field>
+            <field name="type">ir.actions.act_window</field>
+            <field name="res_model">account.invoice.type</field>
+            <field name="view_id" ref="view_account_invoice_type"/>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree</field>
+        </record>
+        <!-- Menu -->
+        <menuitem action="action_account_invoice_type" id="menu_account_invoice_type" sequence="4" parent="account.menu_finance_configuration" />
+
+    </data>
+
+     <data noupdate="1">
+        <record id="ait_normal" model="account.invoice.type">
+            <field name="name">Normal</field>
+        </record>
+        <record id="ait_13" model="account.invoice.type">
+            <field name="name">13%</field>
+        </record>
+        <record id="ait_17" model="account.invoice.type">
+            <field name="name">17%</field>
+        </record>
+        <record id="ait_none" model="account.invoice.type">
+            <field name="name">None</field>
+        </record>
+    </data>
+</openerp>

=== added directory 'account_invoice_line/i18n'
=== added file 'account_invoice_line/i18n/zh_CN.po'
--- account_invoice_line/i18n/zh_CN.po	1970-01-01 00:00:00 +0000
+++ account_invoice_line/i18n/zh_CN.po	2013-08-23 02:20:58 +0000
@@ -0,0 +1,107 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+#	* fc_account_invoice
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0alpha\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-03-29 02:28+0000\n"
+"PO-Revision-Date: 2013-03-29 02:28+0000\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: account
+#: field:account.invoice,supplier_invoice_number:0
+msgid "Supplier Invoice Number"
+msgstr "增值税普票号码"
+
+#. module: account
+#: code:addons/account/account_invoice.py:92
+#, python-format
+msgid "Free Reference"
+msgstr "入库说明"
+
+#. module: fc_account_invoice
+#: field:account.invoice,fapiao_date:0
+msgid "Fapiao Date"
+msgstr "增值税开票日期"
+
+#. module: fc_account_invoice
+#: model:account.invoice.type,name:fc_account_invoice.ait_none
+msgid "None"
+msgstr "无"
+
+#. module: fc_account_invoice
+#: model:ir.actions.act_window,name:fc_account_invoice.action_account_invoice_type
+#: model:ir.model,name:fc_account_invoice.model_account_invoice_type
+#: model:ir.ui.menu,name:fc_account_invoice.menu_account_invoice_type
+msgid "Account Invoice Type"
+msgstr "发票税别"
+
+#. module: fc_account_invoice
+#: field:account.invoice.type,name:0
+msgid "Name"
+msgstr "名称"
+
+#. module: fc_account_invoice
+#: model:account.invoice.type,name:fc_account_invoice.ait_13
+msgid "13%"
+msgstr "13%"
+
+#. module: fc_account_invoice
+#: model:account.invoice.type,name:fc_account_invoice.ait_normal
+msgid "Normal"
+msgstr "普票"
+
+#. module: fc_account_invoice
+#: model:account.invoice.type,name:fc_account_invoice.ait_17
+msgid "17%"
+msgstr "17%"
+
+#. module: fc_account_invoice
+#: model:ir.model,name:fc_account_invoice.model_stock_picking
+msgid "Picking List"
+msgstr "分拣单"
+
+#. module: fc_account_invoice
+#: model:ir.model,name:fc_account_invoice.model_account_invoice_line
+msgid "Invoice Line"
+msgstr "发票明细"
+
+#. module: fc_account_invoice
+#: field:account.invoice.line,amount_subtotal:0
+msgid "Amount (Inc. Tax)"
+msgstr "金额(含税)"
+
+#. module: fc_account_invoice
+#: view:account.invoice.type:0
+msgid "invoice type"
+msgstr "发票税别"
+
+#. module: fc_account_invoice
+#: model:ir.model,name:fc_account_invoice.model_account_invoice
+msgid "Invoice"
+msgstr "发票"
+
+#. module: fc_account_invoice
+#: view:account.invoice:0
+#: field:account.invoice,account_invoice_type:0
+msgid "Invoice Type"
+msgstr "发票税别"
+
+#. module: fc_account_invoice
+#: code:addons/fc_account_invoice/account.py:42
+#, python-format
+msgid "Free Reference"
+msgstr "入库说明"
+
+#. module: fc_account_invoice
+#: field:account.invoice,partner_ref:0
+msgid "Partner Ref"
+msgstr "编号"
+

=== added directory 'account_invoice_line/security'
=== added file 'account_invoice_line/security/ir.model.access.csv'
--- account_invoice_line/security/ir.model.access.csv	1970-01-01 00:00:00 +0000
+++ account_invoice_line/security/ir.model.access.csv	2013-08-23 02:20:58 +0000
@@ -0,0 +1,2 @@
+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+access_account_invoice_type,account.invoice.type,account_invoice_line.model_account_invoice_type,account.group_account_invoice,1,1,1,1

=== added directory 'account_invoice_line/static'
=== added directory 'account_invoice_line/static/description'
=== added file 'account_invoice_line/static/description/account_invoice_line.png'
Binary files account_invoice_line/static/description/account_invoice_line.png	1970-01-01 00:00:00 +0000 and account_invoice_line/static/description/account_invoice_line.png	2013-08-23 02:20:58 +0000 differ
=== added file 'account_invoice_line/static/description/index.html'
--- account_invoice_line/static/description/index.html	1970-01-01 00:00:00 +0000
+++ account_invoice_line/static/description/index.html	2013-08-23 02:20:58 +0000
@@ -0,0 +1,16 @@
+<section class="oe_container">
+    <div class="oe_row">
+    <h2 class="oe_slogan">account_invoice_line Module</h2> 
+    <h3 class="oe_slogan">Individual Invoices for Each Item Product in Invoices</h3>
+    <h4 class="oe_slogan"><a href="http://www.openerp.com.cn";>By Elico Corp</a></h4>
+       <p>This module separates each item in the Customer and Supplier invoices into separate invoices. This allows for each of the separate invoices to be categorized by information type (i.e. company, item, V.A.T., account, etc.) enabling easier search and usage of different search filters.</p>
+                <p>This module also adds more fields that can be filled in the Supplier and Customer invoices which includes:<br>&nbsp; - &nbsp;Account<br>&nbsp; - &nbsp;Journal<br>&nbsp; - &nbsp;Supplier Inv. Ref.<br>&nbsp; - &nbsp;V.A.T. Date<br>&nbsp; - &nbsp;Invoice Type&nbsp;</p>
+        <div class="oe_row_img oe_centered oe_mt32">
+            <img class="oe_picture oe_screenshot" src="account_invoice_line.png">
+        </div>
+    </div>
+     <div class="oe_row oe_centeralign oe_more_space">
+            <a href="http://www.elico-corp.com"; class="oe_button oe_big">Start your <span class="oe_emph">free</span> trial</a>
+        </div>
+        <h4 class="oe_slogan">or</h4>
+</section>
\ No newline at end of file

=== added directory 'account_prepayment/static'
=== added directory 'account_prepayment/static/description'
=== added file 'account_prepayment/static/description/account_invoice_line1.png'
Binary files account_prepayment/static/description/account_invoice_line1.png	1970-01-01 00:00:00 +0000 and account_prepayment/static/description/account_invoice_line1.png	2013-08-23 02:20:58 +0000 differ
=== added file 'account_prepayment/static/description/account_invoice_line2.png'
Binary files account_prepayment/static/description/account_invoice_line2.png	1970-01-01 00:00:00 +0000 and account_prepayment/static/description/account_invoice_line2.png	2013-08-23 02:20:58 +0000 differ
=== added file 'account_prepayment/static/description/index.html'
--- account_prepayment/static/description/index.html	1970-01-01 00:00:00 +0000
+++ account_prepayment/static/description/index.html	2013-08-23 02:20:58 +0000
@@ -0,0 +1,16 @@
+<section class="oe_container">
+    <div class="oe_row">
+    <h2 class="oe_slogan">account_prepayment Module</h2> 
+    <h3 class="oe_slogan">Prepayment Account for Customers and <br>Usage of Prepayment Account for Payments in Purchase Order</h3>
+    <h4 class="oe_slogan"><a href="http://www.openerp.com.cn";>By Elico Corp</a></h4>
+       <p>This module allows for creation of prepayment accounts for Customers. This module also allows for payment to Suppliers in Purchase Orders to be deducted from the Prepayment Accounts instead of just other normal payment accounts. </p>
+        <div class="oe_row_img oe_centered oe_mt32">
+            <img class="oe_picture oe_screenshot" src="account_invoice_line1.png">
+            <img class="oe_picture oe_screenshot" src="account_invoice_line2.png">
+        </div>
+    </div>
+     <div class="oe_row oe_centeralign oe_more_space">
+            <a href="http://www.elico-corp.com"; class="oe_button oe_big">Start your <span class="oe_emph">free</span> trial</a>
+        </div>
+        <h4 class="oe_slogan">or</h4>
+</section>
\ No newline at end of file

=== added directory 'mrp_move_direct'
=== added file 'mrp_move_direct/__init__.py'
--- mrp_move_direct/__init__.py	1970-01-01 00:00:00 +0000
+++ mrp_move_direct/__init__.py	2013-08-23 02:20:58 +0000
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
+#    Author: Andy Lu <andy.lu@xxxxxxxxxxxxxx>
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import stock
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'mrp_move_direct/__openerp__.py'
--- mrp_move_direct/__openerp__.py	1970-01-01 00:00:00 +0000
+++ mrp_move_direct/__openerp__.py	2013-08-23 02:20:58 +0000
@@ -0,0 +1,53 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
+#    Author: Andy Lu <andy.lu@xxxxxxxxxxxxxx>
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+
+{
+    'name': 'MRP support Add or Cancel the moves.',
+    'version': '1.1',
+    'author': 'Andy Lu',
+    'website': 'http://www.openerp.com.cn',
+    'category': 'Manufacturing',
+    'sequence': 18,
+    'summary': 'MRP support Add or Cancel the moves',
+    'images': [],
+    'depends': ['mrp','procurement', 'stock'],
+    'description': """
+MRP support Add or Cancel the moves in OpenERP
+===========================================
+
+The module allows you to:
+* Add new products to consume directly.
+* Cancel(Scrap) products to consume directly.
+* recalculate cost
+
+    """,
+    'data': [
+        'mrp_view.xml',
+    ],
+    'demo': [],
+    'test': [],
+    'installable': True,
+    'application': False,
+    'auto_install': False,
+}
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added directory 'mrp_move_direct/i18n'
=== added file 'mrp_move_direct/i18n/zh_CN.po'
--- mrp_move_direct/i18n/zh_CN.po	1970-01-01 00:00:00 +0000
+++ mrp_move_direct/i18n/zh_CN.po	2013-08-23 02:20:58 +0000
@@ -0,0 +1,248 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+#	* fc_mrp
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-03-12 06:09+0000\n"
+"PO-Revision-Date: 2013-03-12 06:09+0000\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: fc_mrp
+#: code:addons/fc_mrp/stock.py:134
+#, python-format
+msgid "Information"
+msgstr "信息"
+
+#. module: fc_mrp
+#: view:mrp.production:0
+#: view:stock.move.add:0
+msgid "Add Products"
+msgstr "添加产品"
+
+#. module: fc_mrp
+#: code:addons/fc_mrp/stock.py:104
+#, python-format
+msgid "You are moving %.2f %s but only %.2f %s available for this serial number."
+msgstr "你正准备调拨 %.2f %s,但是该批号仅有 %.2f %s 。"
+
+#. module: fc_mrp
+#: model:ir.model,name:fc_mrp.model_mrp_production
+msgid "Manufacturing Order"
+msgstr "生产订单"
+
+#. module: fc_mrp
+#: code:addons/fc_mrp/stock.py:305
+#, python-format
+msgid "Exception!"
+msgstr "例外!"
+
+#. module: fc_mrp
+#: model:ir.model,name:fc_mrp.model_stock_move_add
+msgid "Add new Move for Production Order"
+msgstr "为生产订单添加新原料"
+
+#. module: fc_mrp
+#: field:stock.move.add,product_uos:0
+msgid "Product UOS"
+msgstr "销售单位"
+
+#. module: fc_mrp
+#: field:move.scrap.directly,location_id:0
+#: field:return.scrap.directly,location_id:0
+msgid "Location"
+msgstr "报废库位"
+
+#. module: fc_mrp
+#: code:addons/fc_mrp/stock.py:571
+#: code:addons/fc_mrp/stock.py:572
+#, python-format
+msgid "Exclude the done or cancel Moves:"
+msgstr "已排除“完成”和“取消”的调拨:"
+
+#. module: fc_mrp
+#: field:stock.move.add,product_uos_qty:0
+msgid "Quantity (UOS)"
+msgstr "数量(销售)"
+
+#. module: fc_mrp
+#: field:stock.move.add,product_uom:0
+msgid "Unit of Measure"
+msgstr "单位"
+
+#. module: fc_mrp
+#: field:stock.move.add,date_expected:0
+msgid "Scheduled Date"
+msgstr "计划日期"
+
+#. module: fc_mrp
+#: view:mrp.production:0
+msgid "Cancel Move"
+msgstr "取消调拨"
+
+#. module: fc_mrp
+#: field:return.scrap.directly,return_comment:0
+msgid "From Return Location Moves"
+msgstr "调拨(来自退货库)"
+
+#. module: fc_mrp
+#: model:ir.actions.act_window,name:fc_mrp.move_scrap_dir
+#: view:move.scrap.directly:0
+msgid "Move Scrap Directly"
+msgstr "直接报废"
+
+#. module: fc_mrp
+#: field:move.scrap.directly,product_uom:0
+msgid "Product Unit of Measure"
+msgstr "计量单位"
+
+#. module: fc_mrp
+#: field:return.scrap.directly,not_comment:0
+msgid "Not From Return Locations"
+msgstr "调拨(非来自退货库)"
+
+#. module: fc_mrp
+#: code:addons/fc_mrp/stock.py:173
+#, python-format
+msgid "By changing the quantity here, you accept the new quantity as complete: OpenERP will not automatically generate a Back Order."
+msgstr "在此修改数量,将会完成一个新数量的调拨: OpenERP不会自动拆单。"
+
+#. module: fc_mrp
+#: field:stock.move.add,prodlot_id:0
+msgid "Serial Number"
+msgstr "批号"
+
+#. module: fc_mrp
+#: model:ir.model,name:fc_mrp.model_move_scrap_directly
+msgid "Scrap Products"
+msgstr "报废产品"
+
+#. module: fc_mrp
+#: view:return.scrap.directly:0
+msgid "If you click Ok button, return Moves will be Scraped directly."
+msgstr "若你点击“确定”按钮,选择的来自退货库的调拨将自动报废。"
+
+#. module: fc_mrp
+#: code:addons/fc_mrp/stock.py:305
+#, python-format
+msgid "Can not create the Move related to MO"
+msgstr "不能创建生产订单相关的调拨"
+
+#. module: fc_mrp
+#: model:ir.model,name:fc_mrp.model_return_scrap_directly
+msgid "Scrap Return Products"
+msgstr "报废退货产品"
+
+#. module: fc_mrp
+#: view:move.scrap.directly:0
+#: view:return.scrap.directly:0
+msgid "Ok"
+msgstr "确定"
+
+#. module: fc_mrp
+#: field:move.scrap.directly,product_id:0
+#: field:stock.move.add,product_id:0
+msgid "Product"
+msgstr "产品"
+
+#. module: fc_mrp
+#: view:move.scrap.directly:0
+#: view:return.scrap.directly:0
+msgid "Scrap Location"
+msgstr "报废库位"
+
+#. module: fc_mrp
+#: view:stock.move:0
+msgid "Scrap Directly"
+msgstr "直接报废"
+
+#. module: fc_mrp
+#: field:move.scrap.directly,product_qty:0
+#: field:stock.move.add,product_qty:0
+msgid "Quantity"
+msgstr "数量"
+
+#. module: fc_mrp
+#: model:ir.actions.act_window,name:fc_mrp.return_move_scrap_dir
+msgid "Return Move Scrap Directly"
+msgstr "报废退货调拨"
+
+#. module: fc_mrp
+#: code:addons/fc_mrp/stock.py:172
+#, python-format
+msgid "Warning: No Back Order"
+msgstr "警告: 没有分单"
+
+#. module: fc_mrp
+#: code:addons/fc_mrp/stock.py:103
+#, python-format
+msgid "Insufficient Stock for Serial Number !"
+msgstr "该批次库存数量不足 !"
+
+#. module: fc_mrp
+#: field:stock.move.add,location_id:0
+msgid "Source Location"
+msgstr "来源库位"
+
+#. module: fc_mrp
+#: view:return.scrap.directly:0
+msgid "Move Return Scrap Directly"
+msgstr "报废退货调拨"
+
+#. module: fc_mrp
+#: field:stock.move.add,location_dest_id:0
+msgid "Destination Location"
+msgstr "目标库位"
+
+#. module: fc_mrp
+#: model:ir.model,name:fc_mrp.model_stock_move
+msgid "Stock Move"
+msgstr "库存调拨"
+
+#. module: fc_mrp
+#: model:ir.actions.act_window,name:fc_mrp.action_mo_add_product
+msgid "Add  Products"
+msgstr "添加产品"
+
+#. module: fc_mrp
+#: view:return.scrap.directly:0
+msgid "Are you sure scrap these return moves? "
+msgstr "你是否确认报废这些来自退货的调拨?"
+
+#. module: fc_mrp
+#: code:addons/fc_mrp/stock.py:135
+#, python-format
+msgid "By changing this quantity here, you accept the new quantity as complete: OpenERP will not automatically generate a back order."
+msgstr "在此修改数量,将会完成一个新数量的调拨: OpenERP不会自动拆单。"
+
+#. module: fc_mrp
+#: view:move.scrap.directly:0
+#: view:return.scrap.directly:0
+#: view:stock.move.add:0
+msgid "Cancel"
+msgstr "取消"
+
+#. module: fc_mrp
+#: view:move.scrap.directly:0
+#: view:return.scrap.directly:0
+#: view:stock.move.add:0
+msgid "or"
+msgstr "或者"
+
+#. module: fc_mrp
+#: view:stock.move.add:0
+msgid "Unit Of Measure"
+msgstr "单位"
+
+#. module: fc_mrp
+#: view:stock.move.add:0
+msgid "Stock Moves"
+msgstr "调拨"
+

=== added file 'mrp_move_direct/mrp_view.xml'
--- mrp_move_direct/mrp_view.xml	1970-01-01 00:00:00 +0000
+++ mrp_move_direct/mrp_view.xml	2013-08-23 02:20:58 +0000
@@ -0,0 +1,227 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+        <!-- Production Order -->
+        
+        <record id="view_mo_add_product_form" model="ir.ui.view">
+            <field name="name">Mo Add Product form</field>
+            <field name="model">stock.move.add</field>
+            <field name="arch" type="xml">
+            <form string="Stock Moves" version="7.0">
+                <group>
+                    <group>
+                        <field name="product_id" on_change="onchange_product_id(product_id)"/>
+                        <label for="product_qty"/>
+                        <div>
+                            <field name="product_qty" on_change="onchange_quantity(product_id, product_qty, product_uom, product_uos)" class="oe_inline"/>
+                            <field name="product_uom" string="Unit Of Measure" groups="product.group_uom" class="oe_inline"/>
+                        </div>
+                            <label for="product_uos_qty" groups="product.group_uos"/>
+                            <div groups="product.group_uos">
+                                <field name="product_uos_qty" on_change="onchange_uos_quantity(product_id, product_uos_qty, product_uos, product_uom)" class="oe_inline"/>
+                                <field name="product_uos" on_change="onchange_quantity(product_id, product_qty, product_uom, product_uos)" class="oe_inline"/>
+                            </div>
+                    </group>
+                    <group>                                
+                        <field name="date_expected"/>
+
+                        <field name="location_id" domain="[('usage','=','internal')]"/>
+                        <field name="location_dest_id" domain="[('usage','=','production')]" groups="stock.group_locations"/>
+                        
+                        <label for="prodlot_id"/>
+                        <div>
+                        	<field name="prodlot_id" groups="stock.group_production_lot"
+                                context="{'location_id':location_id, 'product_id':product_id}"
+                                domain="[('product_id','=?',product_id)]"
+                                on_change="onchange_lot_id(prodlot_id,product_qty, location_id, product_id, product_uom)" class="oe_inline"/>
+                        </div>
+                    </group>
+                </group>
+                <footer>
+                    <button name="add_mo_product" string="Add Products" type="object" class="oe_highlight"/>
+	                 or
+	                <button string="Cancel" class="oe_link" special="cancel" />
+                </footer>
+            </form>
+            </field>
+        </record>
+        
+        <record id="action_mo_add_product" model="ir.actions.act_window">
+            <field name="name">Add  Products</field>
+            <field name="res_model">stock.move.add</field>
+            <field name="type">ir.actions.act_window</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">form</field>
+            <field name="domain">[]</field>
+            <field name="target">new</field>
+            <field name="view_id" ref="view_mo_add_product_form"/>
+            <field name="context">{}</field>
+        </record>
+
+        <record id="ir_mo_add_product" model="ir.values">
+            <field name="key2">tree_but_action</field>
+            <field name="model">stock.move.add</field>
+            <field name="name">Add Products</field>
+            <field eval="'ir.actions.act_window,'+str(action_mo_add_product)" name="value"/>
+        </record>
+
+	<!-- Production Order -->
+        <record id="mrp_move_direct_production_form_view" model="ir.ui.view">
+            <field name="name">mrp.production.form</field>
+            <field name="model">mrp.production</field>
+            <field name="type">form</field>
+            <field name="inherit_id" ref="mrp.mrp_production_form_view"/>
+            <field name="arch" type="xml">
+                <xpath expr="//field[@name='move_lines']/tree/button[@string='Scrap Products']" position="after">
+	                	<button name="action_consume_cancel"
+                                        string="Cancel Move" type="object"
+                                        icon="gtk-stop" states="draft,waiting,confirmed,assigned"/>
+	            </xpath>
+	            <xpath expr="//field[@name='move_lines']" position="after">
+	                	<button name="%(mrp_move_direct.action_mo_add_product)d"
+                            string="Add Products" type="action" icon="gtk-justify-fill" states="ready,in_production,confirmed" 
+                            context="{'mo_id': active_id, 'location_id': location_src_id}" colspan="2"/>
+	            </xpath>
+            </field>
+	    </record>
+
+        <!-- record id="view_move_form_mrp_direct" model="ir.ui.view">
+            <field name="name">stock.move.form.mrp.direct</field>
+            <field name="model">stock.move</field>
+            <field name="inherit_id" ref="stock.view_move_form"/>
+            <field name="arch" type="xml">
+            	<xpath expr="//group[@name='destination_grp']" position="after">
+                	<group name="cancel_4mrp" string="Special" groups="mrp.group_mrp_manager">
+	                	<button name="action_cancel" states="draft,waiting,assigned,confirmed" string="_Cancel" type="object"/>
+                    </group>
+	            </xpath>
+            </field>
+	    </record -->	    
+	        
+	    
+       <record id="view_scrap_move_wizard" model="ir.ui.view">
+            <field name="name">Move Scrap Directly</field>
+            <field name="model">move.scrap.directly</field>
+            <field name="arch" type="xml">
+                <form string="Move Scrap Directly" version="7.0">
+                    <separator string="Move Scrap Directly"/>
+                    <group>
+                        <field name="product_id"  readonly="1"/>
+                        <label for="product_qty"/>
+                        <div>
+                            <field name="product_qty" class="oe_inline" readonly="1"/>
+                            <field name="product_uom" class="oe_inline" readonly="1" groups="product.group_uom"/>
+                        </div>
+                        <field name="location_id" string="Scrap Location" widget="selection"
+                            domain="[('usage','!=','view'),('scrap_location','=',True)]" groups="stock.group_locations"/>
+                    </group>
+                    <footer>
+                        <button name="move_scrap_dir" string="Ok" type="object" class="oe_highlight"  />
+                        or
+                        <button string="Cancel" class="oe_link" special="cancel" />
+                    </footer>
+                </form>
+            </field>
+        </record>
+
+        <record id="move_scrap_dir" model="ir.actions.act_window">
+            <field name="name">Move Scrap Directly</field>
+            <field name="type">ir.actions.act_window</field>
+            <field name="res_model">move.scrap.directly</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">form</field>
+            <field name="target">new</field>
+        </record>
+        
+        <record id="view_move_form_dirscrap" model="ir.ui.view">
+            <field name="name">stock.move.form.dirscrap</field>
+            <field name="model">stock.move</field>
+            <field name="inherit_id" ref="stock.view_move_form"/>
+            <field name="arch" type="xml">
+                <xpath expr="/form/sheet//button[@string='Scrap']" position="after">
+                    <button name="%(mrp_move_direct.move_scrap_dir)d"
+                        string="Scrap Directly" type="action"
+                        icon="terp-gtk-jump-to-ltr" context="{'scrap': True}"
+                        states="draft,waiting,confirmed,assigned"/>
+                </xpath>
+            </field>
+        </record>
+        
+        <!--record id="view_move_picking_form_dirscrap" model="ir.ui.view">
+            <field name="name">stock.move.picking.form.discrap</field>
+            <field name="model">stock.move</field>
+            <field name="inherit_id" ref="stock.view_move_picking_form"/>
+            <field name="arch" type="xml">
+                <xpath expr="//button[@string='Scrap']" position="replace">
+                	<button name="%(mrp_move_direct.move_scrap_dir)d"
+                        string="Scrap Directly" type="action"
+                        icon="terp-gtk-jump-to-ltr" context="{'scrap': True}"
+                        states="draft,waiting,confirmed,assigned" />
+                </xpath>
+            </field>
+        </record-->
+
+        <record id="view_move_tree_dirscrap" model="ir.ui.view">
+            <field name="name">stock.move.tree.discrap</field>
+            <field name="model">stock.move</field>
+            <field name="inherit_id" ref="stock.view_move_tree"/>
+            <field name="arch" type="xml">
+                <xpath expr="//field[@name='tracking_id']" position="before">
+                    <button name="%(mrp_move_direct.move_scrap_dir)d"
+                        string="Scrap Directly" type="action"
+                        icon="terp-gtk-jump-to-ltr" context="{'scrap': True}"
+                        states="draft,waiting,confirmed,assigned"/>
+                </xpath>
+            </field>
+        </record>
+
+        <record id="view_move_tree_reception_picking_dirscrap" model="ir.ui.view">
+            <field name="name">stock.move.tree.reception.discrap</field>
+            <field name="model">stock.move</field>
+            <field name="inherit_id" ref="stock.view_move_tree_reception_picking"/>
+            <field name="arch" type="xml">
+                <xpath expr="//field[@name='tracking_id']" position="before">
+                    <button name="%(mrp_move_direct.move_scrap_dir)d"
+                        string="Scrap Directly" type="action"
+                        icon="terp-gtk-jump-to-ltr" context="{'scrap': True}"
+                        states="draft,waiting,confirmed,assigned"/>
+                </xpath>
+            </field>
+        </record>
+        
+        	        
+	    
+       <record id="view_scrap_return_move_wizard" model="ir.ui.view">
+            <field name="name">Scrap Return Move Directly</field>
+            <field name="model">return.scrap.directly</field>
+            <field name="arch" type="xml">
+                <form string="Move Return Scrap Directly" version="7.0">
+                    <separator string="If you click Ok button, return Moves will be Scraped directly."/>                    
+                    <group>
+                        <field name="return_comment" readonly="1"/>
+                        <field name="not_comment" readonly="1"/>
+                        <field name="location_id" string="Scrap Location" widget="selection"
+                            domain="[('usage','!=','view'),('scrap_location','=',True)]" groups="stock.group_locations"/>
+                    </group>
+                    <separator string="Are you sure scrap these return moves? "/>
+                    <footer>
+                        <button name="move_scrap_dir" string="Ok" type="object" class="oe_highlight"  />
+                        or
+                        <button string="Cancel" class="oe_link" special="cancel" />
+                    </footer>
+                </form>
+            </field>
+        </record>
+
+        <act_window name="Return Move Scrap Directly"
+            res_model="return.scrap.directly"
+            src_model="stock.move"
+            key2="client_action_multi"
+            multi="True"
+            view_mode="form"
+            view_type="form"
+            target="new"
+            id="return_move_scrap_dir"/>
+
+    </data>
+</openerp>

=== added directory 'mrp_move_direct/static'
=== added directory 'mrp_move_direct/static/description'
=== added file 'mrp_move_direct/static/description/index (alicia.lim@xxxxxxxxxxxxxx 2013-08-22-16-53-19).html'
--- mrp_move_direct/static/description/index (alicia.lim@xxxxxxxxxxxxxx 2013-08-22-16-53-19).html	1970-01-01 00:00:00 +0000
+++ mrp_move_direct/static/description/index (alicia.lim@xxxxxxxxxxxxxx 2013-08-22-16-53-19).html	2013-08-23 02:20:58 +0000
@@ -0,0 +1,22 @@
+<section class="oe_container oe_website_only">
+     
+        <div class="oe_row oe_more_spaced">
+            <h2 class="oe_slogan">mrp_move direct Module</h2> 
+            <h3 class="oe_slogan">Add or Cancel Raw Material in Manufacturing Orders</h3>
+            <div class="oe_span6">
+                <p>This module allows for modification to be done directly to the consumed item in a manufacturing order. Users will be able to completely scrapped an item or add a new item that will be used in the manufacturing process of the finish product without having to change the bill of materials.&nbsp;</p>
+                <p>Features:<br />  - Add new raw material item to be consumed in the MO<br />  - Cancel/remove raw material item to be consumed in the MO&nbsp;</p>
+                <p>This module also allows for users to completely scrap an item in Stock Moves.</p>
+                <img class="oe_picture" src="mrp_move_direct1.png">
+            </div>
+            <div class="oe_span6">
+                
+            </div>
+        </div>
+        <div class="oe_row oe_centeralign oe_more_space">
+            <a href="http://www.elico-corp.com"; class="oe_button oe_big">Start your <span class="oe_emph">free</span> trial</a>
+        </div>
+        <h4 class="oe_slogan">or</h4>
+    
+
+    </section>
\ No newline at end of file

=== added file 'mrp_move_direct/static/description/index.html'
--- mrp_move_direct/static/description/index.html	1970-01-01 00:00:00 +0000
+++ mrp_move_direct/static/description/index.html	2013-08-23 02:20:58 +0000
@@ -0,0 +1,29 @@
+<section class="oe_container oe_dark">
+    <div class="oe_row oe_padded">
+  				<h2 class="oe_slogan">mrp_move direct Module</h2> 
+            <h3 class="oe_slogan">Add or Cancel Raw Material in Manufacturing Orders</h3>
+            <h4 class="oe_slogan"><a href="http://www.openerp.com.cn";>By Elico Corp</a></h4>    
+            <div class="oe_span12">
+            <p>This module allows for modification to be done directly to the consumed item in a manufacturing order. Users will be able to completely scrapped an item or add a new item that will be used in the manufacturing process of the finish product without having to change the bill of materials.&nbsp;</p>
+				<p>Features:<br />  - Add new raw material item to be consumed in the MO<br />  - Cancel/remove raw material item to be consumed in the MO&nbsp;</p>
+            <p>This module also allows for users to completely scrap an item in Stock Moves.</p>            
+            </div>
+            <div class="oe_span4">
+            <div class="oe_row_img oe_centered">
+            <img class="oe_picture oe_screenshot" src="mrp_move_direct1.png">
+            </div>
+        </div>
+        <div class="oe_span4 ">
+            <img class="oe_picture oe_screenshot" src="mrp_move_direct2.png">
+            <p></p>
+        </div>
+        <div class="oe_span4 ">
+            <img class="oe_picture oe_screenshot" src="mrp_move_direct3.png">
+            <p></p>
+        </div>
+    </div>
+    <div class="oe_row oe_centeralign oe_more_space">
+            <a href="http://www.elico-corp.com"; class="oe_button oe_big">Start your <span class="oe_emph">free</span> trial</a>
+        </div>
+        <h4 class="oe_slogan">or</h4>
+</section>
\ No newline at end of file

=== added file 'mrp_move_direct/static/description/mrp_move_direct1.png'
Binary files mrp_move_direct/static/description/mrp_move_direct1.png	1970-01-01 00:00:00 +0000 and mrp_move_direct/static/description/mrp_move_direct1.png	2013-08-23 02:20:58 +0000 differ
=== added file 'mrp_move_direct/static/description/mrp_move_direct2.png'
Binary files mrp_move_direct/static/description/mrp_move_direct2.png	1970-01-01 00:00:00 +0000 and mrp_move_direct/static/description/mrp_move_direct2.png	2013-08-23 02:20:58 +0000 differ
=== added file 'mrp_move_direct/static/description/mrp_move_direct3.png'
Binary files mrp_move_direct/static/description/mrp_move_direct3.png	1970-01-01 00:00:00 +0000 and mrp_move_direct/static/description/mrp_move_direct3.png	2013-08-23 02:20:58 +0000 differ
=== added file 'mrp_move_direct/stock.py'
--- mrp_move_direct/stock.py	1970-01-01 00:00:00 +0000
+++ mrp_move_direct/stock.py	2013-08-23 02:20:58 +0000
@@ -0,0 +1,714 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
+#    Author: Andy Lu <andy.lu@xxxxxxxxxxxxxx>
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv import fields, osv
+from openerp.tools.translate import _
+import openerp.addons.decimal_precision as dp
+from openerp import netsvc
+from openerp.tools import float_compare,float_round
+from openerp import SUPERUSER_ID
+import time
+import os
+
+class stock_move_add(osv.TransientModel):
+    _name = "stock.move.add"
+    _description = "Add new Move for Production Order"
+
+    _columns = {
+        'date_expected': fields.datetime('Scheduled Date', required=True),
+        'product_id': fields.many2one('product.product', 'Product', required=True, domain=[('type','<>','service')]),
+
+        'product_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product Unit of Measure'), required=True),
+        'product_uom': fields.many2one('product.uom', 'Unit of Measure', required=True ),
+        'product_uos_qty': fields.float('Quantity (UOS)', digits_compute=dp.get_precision('Product Unit of Measure')),
+        'product_uos': fields.many2one('product.uom', 'Product UOS'),
+        'location_id': fields.many2one('stock.location', 'Source Location', required=True),
+        'location_dest_id': fields.many2one('stock.location', 'Destination Location', required=True),
+        'prodlot_id': fields.many2one('stock.production.lot', 'Serial Number'),
+    }
+
+    def _default_location_destination(self, cr, uid, context=None):
+        """ Gets default address of partner for destination location
+        @return: Address id or False
+        """
+        if context is None:
+            context = {}
+        if not context.get('mo_id', False) or not context.get('active_id', False) :
+            mod_obj = self.pool.get('ir.model.data')
+            location_model, location_id = mod_obj.get_object_reference(cr, uid, 'stock', 'stock_location_production')
+        else:
+            mrp_obj = self.pool.get('mrp.production')
+            production = mrp_obj.browse(cr, uid, context.get('mo_id', False) or context.get('active_id', False), context)
+            location_id = production.product_id.property_stock_production.id
+        return location_id
+
+    def _default_location_source(self, cr, uid, context=None):
+        """ Gets default address of partner for source location
+        @return: Address id or False
+        """
+        if context is None:
+            context = {}
+        return context.get('location_id', False)
+
+    _defaults = {
+        'location_id': _default_location_source,
+        'location_dest_id': _default_location_destination,
+        'product_qty': 1.0,
+        'date_expected': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
+    }
+
+    def onchange_lot_id(self, cr, uid, ids, prodlot_id=False, product_qty=False,
+                        loc_id=False, product_id=False, uom_id=False, context=None):
+        """ On change of production lot gives a warning message.
+        @param prodlot_id: Changed production lot id
+        @param product_qty: Quantity of product
+        @param loc_id: Location id
+        @param product_id: Product id
+        @return: Warning message
+        """
+        if not prodlot_id or not loc_id:
+            return {}
+        ctx = context and context.copy() or {}
+        ctx['location_id'] = loc_id
+        ctx.update({'raise-exception': True})
+        uom_obj = self.pool.get('product.uom')
+        product_obj = self.pool.get('product.product')
+        product_uom = product_obj.browse(cr, uid, product_id, context=ctx).uom_id
+        prodlot = self.pool.get('stock.production.lot').browse(cr, uid, prodlot_id, context=ctx)
+        location = self.pool.get('stock.location').browse(cr, uid, loc_id, context=ctx)
+        uom = uom_obj.browse(cr, uid, uom_id, context=ctx)
+        amount_actual = uom_obj._compute_qty_obj(cr, uid, product_uom, prodlot.stock_available, uom, context=ctx)
+        warning = {}
+        if (location.usage == 'internal') and (product_qty > (amount_actual or 0.0)):
+            warning = {
+                'title': _('Insufficient Stock for Serial Number !'),
+                'message': _('You are moving %.2f %s but only %.2f %s available for this serial number.') % (product_qty, uom.name, amount_actual, uom.name)
+            }
+        return {'warning': warning}
+
+    def onchange_quantity(self, cr, uid, ids, product_id, product_qty,
+                          product_uom, product_uos):
+        """ On change of product quantity finds UoM and UoS quantities
+        @param product_id: Product id
+        @param product_qty: Changed Quantity of product
+        @param product_uom: Unit of measure of product
+        @param product_uos: Unit of sale of product
+        @return: Dictionary of values
+        """
+        result = {
+                  'product_uos_qty': 0.00
+          }
+        warning = {}
+
+        if (not product_id) or (product_qty <=0.0):
+            result['product_qty'] = 0.0
+            return {'value': result}
+
+        product_obj = self.pool.get('product.product')
+        uos_coeff = product_obj.read(cr, uid, product_id, ['uos_coeff'])
+        
+        # Warn if the quantity was decreased 
+        if ids:
+            for move in self.read(cr, uid, ids, ['product_qty']):
+                if product_qty < move['product_qty']:
+                    warning.update({
+                       'title': _('Information'),
+                       'message': _("By changing this quantity here, you accept the "
+                                "new quantity as complete: OpenERP will not "
+                                "automatically generate a back order.") })
+                break
+
+        if product_uos and product_uom and (product_uom != product_uos):
+            result['product_uos_qty'] = product_qty * uos_coeff['uos_coeff']
+        else:
+            result['product_uos_qty'] = product_qty
+
+        return {'value': result, 'warning': warning}
+
+    def onchange_uos_quantity(self, cr, uid, ids, product_id, product_uos_qty,
+                          product_uos, product_uom):
+        """ On change of product quantity finds UoM and UoS quantities
+        @param product_id: Product id
+        @param product_uos_qty: Changed UoS Quantity of product
+        @param product_uom: Unit of measure of product
+        @param product_uos: Unit of sale of product
+        @return: Dictionary of values
+        """
+        result = {
+                  'product_qty': 0.00
+          }
+        warning = {}
+
+        if (not product_id) or (product_uos_qty <=0.0):
+            result['product_uos_qty'] = 0.0
+            return {'value': result}
+
+        product_obj = self.pool.get('product.product')
+        uos_coeff = product_obj.read(cr, uid, product_id, ['uos_coeff'])
+        
+        # Warn if the quantity was decreased 
+        for move in self.read(cr, uid, ids, ['product_uos_qty']):
+            if product_uos_qty < move['product_uos_qty']:
+                warning.update({
+                   'title': _('Warning: No Back Order'),
+                   'message': _("By changing the quantity here, you accept the "
+                                "new quantity as complete: OpenERP will not "
+                                "automatically generate a Back Order.") })
+                break
+
+        if product_uos and product_uom and (product_uom != product_uos):
+            result['product_qty'] = product_uos_qty / uos_coeff['uos_coeff']
+        else:
+            result['product_qty'] = product_uos_qty
+        return {'value': result, 'warning': warning}
+        
+    def onchange_product_id(self, cr, uid, ids, prod_id=False):
+        """ On change of product id, if finds UoM, UoS, quantity and UoS quantity.
+        @param prod_id: Changed Product id
+        @return: Dictionary of values
+        """
+        if not prod_id:
+            return {}
+        
+        product = self.pool.get('product.product').browse(cr, uid, [prod_id], context=None)[0]
+        uos_id  = product.uos_id and product.uos_id.id or False
+        result = {
+            'product_uom': product.uom_id.id,
+            'product_uos': uos_id,
+            'product_qty': 1.00,
+            'product_uos_qty' : self.pool.get('stock.move').onchange_quantity(cr, uid, ids, prod_id, 1.00, product.uom_id.id, uos_id)['value']['product_uos_qty'],
+            'prodlot_id' : False,
+        }
+        return {'value': result}
+    
+    def add_production_line_procurement(self, cr, uid, new_move, production, shipment_move_id, context=None):
+        wf_service = netsvc.LocalService("workflow")
+        procurement_order = self.pool.get('procurement.order')
+
+        location_id = new_move.location_id.id or production.location_src_id.id
+        date_planned = new_move.date_expected or production.date_planned
+        procurement_name = (production.origin or '').split(':')[0] + ':' + production.name
+        procurement_id = procurement_order.create(cr, uid, {
+                    'name': procurement_name,
+                    'origin': procurement_name,
+                    'date_planned': date_planned,
+                    'product_id': new_move.product_id.id,
+                    'product_qty': new_move.product_qty,
+                    'product_uom': new_move.product_uom.id,
+                    'product_uos_qty': new_move.product_uos and new_move.product_qty or False,
+                    'product_uos': new_move.product_uos and new_move.product_uos.id or False,
+                    'location_id': location_id,
+                    'procure_method': new_move.product_id.procure_method,
+                    'move_id': shipment_move_id,
+                    'company_id': production.company_id.id,
+                })
+        wf_service.trg_validate(uid, procurement_order._name, procurement_id, 'button_confirm', cr)
+        wf_service.trg_validate(uid, procurement_order._name, procurement_id, 'button_check', cr)
+        return procurement_id
+
+    def add_production_internal_shipment_line(self, cr, uid, new_move, production, consume_move_id=False, context=None):
+        stock_move = self.pool.get('stock.move')
+        date_planned = new_move.date_expected or production.date_planned
+        # Internal shipment is created for Stockable and Consumer Products
+        if new_move.product_id.type not in ('product', 'consu'):
+            return False
+        source_location_id = new_move.location_id.id or production.location_src_id.id
+        
+        move_id = stock_move.create(cr, uid, {
+                        'name': production.name,
+                        #'picking_id': shipment_id,
+                        'product_id': new_move.product_id.id,
+                        'product_qty': new_move.product_qty,
+                        'product_uom': new_move.product_uom.id,
+                        'product_uos_qty': new_move.product_uos and new_move.product_uos_qty or False,
+                        'product_uos': new_move.product_uos and new_move.product_uos.id or False,
+                        'date': date_planned,
+                        'date_expected': date_planned,
+                        'move_dest_id': consume_move_id,
+                        'location_id': source_location_id,
+                        'location_dest_id': source_location_id,
+                        'state': 'waiting',
+                        'company_id': production.company_id.id,
+                })
+
+        if production.picking_id:
+            if production.picking_id.state != 'done':
+                new_move = { 'picking_id': production.picking_id.id }
+            else:
+                default = {}
+                # SHOULD USE ir_sequence.next_by_code() or ir_sequence.next_by_id()
+                default['name'] = self.pool.get('ir.sequence').get(cr, uid, production.picking_id.type)
+                default['move_lines'] = False
+                default['state'] = 'auto'
+                new_picking = self.pool.get('stock.picking').copy(cr, uid, production.picking_id.id, default, context)
+                if new_picking:
+                    new_move = { 'picking_id': new_picking }
+                    production.write({'picking_id':new_picking}, context=context)
+            stock_move.write(cr, uid, [move_id], new_move, context)
+            wf_service = netsvc.LocalService("workflow")
+            if production.picking_id.state == 'done':
+                wf_service.trg_validate(uid, 'stock.picking', production.picking_id.id, 'button_confirm', cr)
+
+        return move_id
+
+    def add_production_consume_line(self, cr, uid, new_move, production, context=None):
+        stock_move = self.pool.get('stock.move')
+
+        # Internal shipment is created for Stockable and Consumer Products
+        if new_move.product_id.type not in ('product', 'consu'):
+            return False
+        destination_location_id = new_move.location_dest_id.id or production.product_id.property_stock_production.id
+        source_location_id = new_move.location_id.id or production.location_src_id.id
+        move_id = stock_move.create(cr, uid, {
+            'name': production.name,
+            'date': new_move.date_expected,
+            'date_expected': new_move.date_expected,
+            'product_id': new_move.product_id.id,
+            'product_qty': new_move.product_qty,
+            'product_uom': new_move.product_uom.id,
+            'product_uos_qty': new_move.product_uos and new_move.product_uos_qty or False,
+            'product_uos': new_move.product_uos and new_move.product_uos.id or False,
+            'location_id': source_location_id,
+            'location_dest_id': destination_location_id,
+            'move_dest_id': production.move_prod_id.id,
+            'state': 'waiting',
+            'company_id': production.company_id.id,
+        })
+        production.write({'move_lines': [(4, move_id)]}, context=context)
+        return move_id
+
+    def add_mo_product(self, cr, uid, ids, context=None):
+        """ Add new move.
+        @return: True.
+        """        
+        if context is None:
+            context = {}
+        
+        if not context.get('mo_id', False) or not context.get('active_id', False) :
+            raise osv.except_osv(_('Exception!'), _('Can not create the Move related to MO'))
+        
+        new_move = self.browse(cr, uid, ids, context)[0]
+        
+        mrp_obj = self.pool.get('mrp.production')
+        production = mrp_obj.browse(cr, uid, context.get('mo_id', False) or context.get('active_id', False), context)
+
+        prod_line_obj = self.pool.get('mrp.production.product.line')
+        line_ids = prod_line_obj.search(cr, uid, [('production_id','=', production.id),('product_id','=', new_move.product_id.id)], context=context)
+        if line_ids:
+            pl = prod_line_obj.browse(cr, uid, line_ids[0]) 
+            qty_in_line_uos = False           
+            product_uom_obj = self.pool.get('product.uom')
+            qty_in_line_uom = product_uom_obj._compute_qty(cr, uid, pl.product_uom.id, new_move.product_qty, to_uom_id=new_move.product_uom.id)
+            vals={'product_qty': pl.product_qty + qty_in_line_uom}
+            if pl.product_uos and new_move.product_uos and pl.product_uos_qty and new_move.product_uos_qty:
+                qty_in_line_uos = product_uom_obj._compute_qty(cr, uid, pl.product_uos.id, new_move.product_uos_qty or 0.0, to_uom_id=new_move.product_uos.id)
+                vals={'product_uos_qty': pl.product_uos_qty or 0.0 + qty_in_line_uos}
+            prod_line_obj.write(cr, uid, [pl.id], vals)
+            
+            found = False
+            for move in production.move_lines:
+                if move.product_id.id == new_move.product_id.id:
+                    vals={'product_qty': move.product_qty + qty_in_line_uom}
+                    if qty_in_line_uos:
+                        vals={'product_uos_qty': move.product_uos_qty or 0.0 + qty_in_line_uos}
+                    self.pool.get('stock.move').write(cr, uid, [move.id], vals)
+                    found = True
+                    break
+            consume_move_id = False
+            if not found:
+                consume_move_id = self.add_production_consume_line(cr, uid, new_move, production, context=context)
+        else:
+            line = {
+                'name': new_move.product_id.name,
+                'product_id': new_move.product_id.id,
+                'product_qty': new_move.product_qty,
+                'product_uom': new_move.product_uom.id,
+                'product_uos_qty': new_move.product_uos and new_move.product_uos_qty or False,
+                'product_uos': new_move.product_uos and new_move.product_uos.id or False,
+                'production_id': production.id,
+            }
+            prod_line_obj.create(cr, uid, line)
+            consume_move_id = self.add_production_consume_line(cr, uid, new_move, production, context=context)
+        #shipment_id = self._make_production_internal_shipment(cr, uid, production, context=context)
+        
+        shipment_move_id = self.add_production_internal_shipment_line(cr, uid, new_move, production, consume_move_id, context=context)
+        procurement_id = self.add_production_line_procurement(cr, uid, new_move, production, shipment_move_id, context=context)
+        self.pool.get('procurement.order').write(cr, uid, [procurement_id], {'close_move':  True}, context=context)
+        
+        return True
+stock_move_add()
+
+class stock_move(osv.Model):
+    _inherit = "stock.move"
+    
+    _columns = {
+        'cal_cost': fields.boolean('Calculated Cost'),
+    }
+    _defaults = {
+        'cal_cost': False,
+    }   
+    #
+    # Cancel move => cancel others move and pickings
+    #
+    def action_consume_cancel(self, cr, uid, ids, context=None):
+        """ Cancels the moves and if all moves are cancelled it cancels the picking.
+        @return: True
+        """
+        if not ids:
+            return True
+        
+        new_move = self.browse(cr, uid, ids, context)[0]
+        
+        sm_ids = self.search(cr, uid, [('move_dest_id','=', new_move.id)], context=context)
+        sp_picking = False
+        if sm_ids:
+            for move in self.browse(cr, uid, sm_ids):
+                sp_picking = move.picking_id
+                if move.state == 'done':
+                    self.write(cr, uid, [move.id], {'state': 'cancel'})
+                else:
+                    self.action_cancel(cr, uid, [move.id], context=context)
+        if sp_picking:            
+            mrp_obj = self.pool.get('mrp.production')
+            mo_ids = mrp_obj.search(cr, uid, [('picking_id','=', sp_picking.id)], context=context)
+            if mo_ids:
+                prod_line_obj = self.pool.get('mrp.production.product.line')
+                ml_ids = prod_line_obj.search(cr, uid, [('production_id','=', mo_ids[0]),('product_id','=', new_move.product_id.id)], context=context)
+                if ml_ids:
+                    prod_line = prod_line_obj.browse(cr, uid, ml_ids)[0]
+                    compare = float_compare(prod_line.product_qty, new_move.product_qty, precision_rounding=4)
+                    if compare == 0:
+                        prod_line_obj.unlink(cr, uid, [prod_line.id], context=context)
+                    elif compare > 0:
+                        prod_line_obj.write(cr, uid, [prod_line.id], {'product_qty': prod_line.product_qty - new_move.product_qty})
+                    
+        self.action_cancel(cr, uid, [new_move.id], context=context)
+
+stock_move()
+
+class mrp_production(osv.osv):
+    """
+    Production Orders / Manufacturing Orders
+    """
+    _inherit = 'mrp.production'
+
+    _columns = {
+        'move_lines2': fields.many2many('stock.move', 'mrp_production_move_ids', 'production_id', 'move_id', 'Consumed Products',
+            domain=[('state','in', ('done',''))], readonly=True, states={'draft':[('readonly',False)]}),
+    }
+
+    def action_produce(self, cr, uid, production_id, production_qty, production_mode, context=None):
+        
+        #LY Start COPY from standard add rounding in 0510
+        """ To produce final product based on production mode (consume/consume&produce).
+        If Production mode is consume, all stock move lines of raw materials will be done/consumed.
+        If Production mode is consume & produce, all stock move lines of raw materials will be done/consumed
+        and stock move lines of final product will be also done/produced.
+        @param production_id: the ID of mrp.production object
+        @param production_qty: specify qty to produce
+        @param production_mode: specify production mode (consume/consume&produce).
+        @return: True
+        """
+        stock_mov_obj = self.pool.get('stock.move')
+        production = self.browse(cr, uid, production_id, context=context)
+
+        produced_qty = 0
+        for produced_product in production.move_created_ids2:
+            if (produced_product.scrapped) or (produced_product.product_id.id != production.product_id.id):
+                continue
+            produced_qty += produced_product.product_qty
+        if production_mode in ['consume','consume_produce']:
+            consumed_data = {}
+
+            # Calculate already consumed qtys
+            for consumed in production.move_lines2:
+                if consumed.scrapped:
+                    continue
+                if not consumed_data.get(consumed.product_id.id, False):
+                    consumed_data[consumed.product_id.id] = 0
+                consumed_data[consumed.product_id.id] += consumed.product_qty
+
+            # Find product qty to be consumed and consume it
+            for scheduled in production.product_lines:
+
+                # total qty of consumed product we need after this consumption
+                total_consume = ((production_qty + produced_qty) * scheduled.product_qty / production.product_qty)
+
+                # qty available for consume and produce
+                qty_avail = scheduled.product_qty - consumed_data.get(scheduled.product_id.id, 0.0)
+
+                if qty_avail <= 0.0:
+                    # there will be nothing to consume for this raw material
+                    continue
+
+                raw_product = [move for move in production.move_lines if move.product_id.id==scheduled.product_id.id]
+                if raw_product:
+                    # qtys we have to consume
+                    qty = total_consume - consumed_data.get(scheduled.product_id.id, 0.0)
+                    if float_compare(qty, qty_avail, precision_rounding=scheduled.product_id.uom_id.rounding) == 1:
+                        # if qtys we have to consume is more than qtys available to consume
+                        prod_name = scheduled.product_id.name_get()[0][1]
+                        raise osv.except_osv(_('Warning!'), _('You are going to consume total %s quantities of "%s".\nBut you can only consume up to total %s quantities.') % (qty, prod_name, qty_avail))
+                    if qty <= 0.0:
+                        # we already have more qtys consumed than we need
+                        continue
+
+                    qty = round(qty,3)#LY 0510
+                    raw_product[0].action_consume(qty, raw_product[0].location_id.id, context=context)
+
+        if production_mode == 'consume_produce':
+            # To produce remaining qty of final product
+            #vals = {'state':'confirmed'}
+            #final_product_todo = [x.id for x in production.move_created_ids]
+            #stock_mov_obj.write(cr, uid, final_product_todo, vals)
+            #stock_mov_obj.action_confirm(cr, uid, final_product_todo, context)
+            produced_products = {}
+            for produced_product in production.move_created_ids2:
+                if produced_product.scrapped:
+                    continue
+                if not produced_products.get(produced_product.product_id.id, False):
+                    produced_products[produced_product.product_id.id] = 0
+                produced_products[produced_product.product_id.id] += produced_product.product_qty
+
+            for produce_product in production.move_created_ids:
+                produced_qty = produced_products.get(produce_product.product_id.id, 0)
+                subproduct_factor = self._get_subproduct_factor(cr, uid, production.id, produce_product.id, context=context)
+                rest_qty = (subproduct_factor * production.product_qty) - produced_qty
+
+                if rest_qty < production_qty:
+                    prod_name = produce_product.product_id.name_get()[0][1]
+                    raise osv.except_osv(_('Warning!'), _('You are going to produce total %s quantities of "%s".\nBut you can only produce up to total %s quantities.') % (production_qty, prod_name, rest_qty))
+                if rest_qty > 0 :
+                    stock_mov_obj.action_consume(cr, uid, [produce_product.id], (subproduct_factor * production_qty), context=context)
+
+        for raw_product in production.move_lines2:
+            new_parent_ids = []
+            parent_move_ids = [x.id for x in raw_product.move_history_ids]
+            for final_product in production.move_created_ids2:
+                if final_product.id not in parent_move_ids:
+                    new_parent_ids.append(final_product.id)
+            for new_parent_id in new_parent_ids:
+                stock_mov_obj.write(cr, uid, [raw_product.id], {'move_history_ids': [(4,new_parent_id)]})
+
+        wf_service = netsvc.LocalService("workflow")
+        wf_service.trg_validate(uid, 'mrp.production', production_id, 'button_produce_done', cr)
+        
+        
+        #LY END COPY
+        #if super(mrp_production, self).action_produce(cr, uid, production_id, production_qty, production_mode, context=context):
+        if production_mode == 'consume':
+            return True
+        move_obj = self.pool.get('stock.move')
+        product_uom_obj = self.pool.get('product.uom')
+        product_obj = self.pool.get('product.product')
+        plan_obj = self.pool.get('procurement.order')
+        production = self.browse(cr, uid, production_id, context=context)
+        if production.product_id.cost_method == 'standard':
+            return True
+
+        sm_ids = move_obj.search(cr, uid, [('name','=', production.name), ('state', '!=', 'done'), ('move_dest_id', '!=', False)], context=context)
+        if sm_ids:                
+            plan_ids = plan_obj.search(cr, uid, [('move_id','in', sm_ids)], context=context)
+            plan_obj.action_done(cr, uid, plan_ids)
+
+        cost_price = 0.0
+        for move in production.move_lines2:
+            if move.scrapped or move.state == 'cancel' or move.cal_cost:
+                continue
+            vals = {'cal_cost': True}
+            if not move.price_unit:
+                if move.product_uom.id == move.product_id.uom_id.id:
+                    price_unit = move.product_id.standard_price
+                else:                        
+                    default_uom = move.product_id.uom_id.id
+                    price_unit = product_uom_obj._compute_price(cr, uid, default_uom, move.product_qty, move.product_uom.id)
+                vals['price_unit'] = price_unit
+            else:
+                price_unit = move.price_unit
+            move_obj.write(cr, uid, [move.id], vals, context=context)
+            cost_price += (move.product_qty * price_unit)
+        
+        qty_available = production.product_id.qty_available
+        total_prod = 0.0
+        for prod_id in production.move_created_ids2:
+            if prod_id.product_uom.id == prod_id.product_id.uom_id.id:
+                total_prod += prod_id.product_qty
+            else:                        
+                total_prod += prod_id.product_qty * prod_id.product_id.product_uom.factor * prod_id.product_uom.factor
+        
+        compare = float_compare(qty_available, 0.0, precision_rounding=4)
+        if compare == 0:
+            price_unit = cost_price / production_qty
+        else:
+            price_unit = ((qty_available - production_qty) * production.product_id.standard_price + cost_price ) / (qty_available)
+        #price_unit = ( qty_available * production.product_id.standard_price + cost_price) / (qty_available + production_qty)
+        digits = self.pool.get('decimal.precision').precision_get(cr, SUPERUSER_ID, 'Product Price')
+        price_unit = float_round(price_unit, precision_digits=digits)
+        move_ids = [ move.id for move in production.move_created_ids2 if not move.price_unit]
+        move_obj.write(cr, uid, move_ids, {'price_unit':  price_unit}, context=context)
+        product_obj.write(cr, uid, [production.product_id.id], {'standard_price': price_unit}, context=context)
+        
+        return True
+
+class move_scrap_directly(osv.TransientModel):
+    _name = "move.scrap.directly"
+    _description = "Scrap Products"
+    #_inherit = "stock.move.consume"
+
+    _columns = {
+        'product_id': fields.many2one('product.product', 'Product', required=True, select=True),
+        'product_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product Unit of Measure'), required=True),
+        'product_uom': fields.many2one('product.uom', 'Product Unit of Measure', required=True),
+        'location_id': fields.many2one('stock.location', 'Location', required=True)
+    }
+
+    _defaults = {
+        'location_id': lambda *x: False
+    }
+
+    def default_get(self, cr, uid, fields, context=None):
+        """ Get default values
+        @param self: The object pointer.
+        @param cr: A database cursor
+        @param uid: ID of the user currently logged in
+        @param fields: List of fields for default value
+        @param context: A standard dictionary
+        @return: default values of fields
+        """
+        if context is None:
+            context = {}
+        res = super(move_scrap_directly, self).default_get(cr, uid, fields, context=context)
+        move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
+        location_obj = self.pool.get('stock.location')
+        scrpaed_location_ids = location_obj.search(cr, uid, [('scrap_location','=',True)])
+
+        if 'product_id' in fields:
+            res.update({'product_id': move.product_id.id})
+        if 'product_uom' in fields:
+            res.update({'product_uom': move.product_uom.id})
+        if 'product_qty' in fields:
+            res.update({'product_qty': move.product_qty})
+        if 'location_id' in fields:
+            if scrpaed_location_ids:
+                res.update({'location_id': scrpaed_location_ids[0]})
+            else:
+                res.update({'location_id': False})
+
+        return res
+
+    def move_scrap_dir(self, cr, uid, ids, context=None):
+        """ To move scrapped products
+        @param self: The object pointer.
+        @param cr: A database cursor
+        @param uid: ID of the user currently logged in
+        @param ids: the ID or list of IDs if we want more than one
+        @param context: A standard dictionary
+        @return:
+        """
+        if context is None:
+            context = {}
+        move_obj = self.pool.get('stock.move')
+        move_ids = context['active_ids']
+        for data in self.browse(cr, uid, ids):
+            move_obj.write(cr, uid, move_ids,
+                {'location_dest_id': data.location_id.id}, context=context)
+            move_obj.action_done(cr, uid, move_ids, context=context)
+        return {'type': 'ir.actions.act_window_close'}
+move_scrap_directly()
+
+class return_scrap_directly(osv.TransientModel):
+    _name = "return.scrap.directly"
+    _description = "Scrap Return Products"
+
+    _columns = {
+        'location_id': fields.many2one('stock.location', 'Location', required=True),
+        'return_comment': fields.text('From Return Location Moves'),
+        'not_comment': fields.text('Not From Return Locations'),
+    }
+
+    _defaults = {
+        'location_id': lambda *x: False
+    }
+
+    def default_get(self, cr, uid, fields, context=None):
+        """ Get default values
+        @param self: The object pointer.
+        @param cr: A database cursor
+        @param uid: ID of the user currently logged in
+        @param fields: List of fields for default value
+        @param context: A standard dictionary
+        @return: default values of fields
+        """
+        if context is None:
+            context = {}
+        res = super(return_scrap_directly, self).default_get(cr, uid, fields, context=context)
+        moves = self.pool.get('stock.move').browse(cr, uid, context['active_ids'], context=context)
+        location_obj = self.pool.get('stock.location')
+        scrpaed_location_ids = location_obj.search(cr, uid, [('scrap_location','=',True)])
+
+        if 'location_id' in fields:
+            if scrpaed_location_ids:
+                res.update({'location_id': scrpaed_location_ids[0]})
+            else:
+                res.update({'location_id': False})
+
+        return_move = _('Exclude the done or cancel Moves:')
+        not_return_move = _('Exclude the done or cancel Moves:')
+        for move in moves:
+            if move.state in ('done','cancel'):
+                continue
+            if move.location_id.location_return:
+                return_move = os.linesep.join([return_move, '-'.join([move.name, move.product_id.name or '', move.location_id.name, move.location_dest_id.name])])
+            else:
+                not_return_move = os.linesep.join([not_return_move, '-'.join([move.name, move.product_id.name or '', move.location_id.name, move.location_dest_id.name])])
+
+        if 'return_comment' in fields:
+            res.update({'return_comment': return_move})
+        if 'not_comment' in fields: 
+            res.update({'not_comment': not_return_move})
+
+        return res
+
+    def move_scrap_dir(self, cr, uid, ids, context=None):
+        """ To move scrapped products
+        @param self: The object pointer.
+        @param cr: A database cursor
+        @param uid: ID of the user currently logged in
+        @param ids: the ID or list of IDs if we want more than one
+        @param context: A standard dictionary
+        @return:
+        """
+        if context is None:
+            context = {}
+        move_obj = self.pool.get('stock.move')
+        move_ids = []
+        for move in move_obj.browse(cr, uid, context['active_ids'], context=context):
+            if move.state not in ('done','cancel') and move.location_id.location_return:
+                move_ids.append(move.id)
+        if move_ids:
+            for data in self.browse(cr, uid, ids):
+                move_obj.write(cr, uid, move_ids,
+                               {'location_dest_id': data.location_id.id}, context=context)
+                move_obj.action_done(cr, uid, move_ids, context=context)
+        return {'type': 'ir.actions.act_window_close'}
+return_scrap_directly()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file

=== modified file 'product_supplier_info/static/description/index.html'
--- product_supplier_info/static/description/index.html	2013-08-20 11:04:13 +0000
+++ product_supplier_info/static/description/index.html	2013-08-23 02:20:58 +0000
@@ -1,17 +1,17 @@
 <section class="oe_container">
-    <div class="oe_row oe_spaced">
-        <h2 class="oe_slogan">product_supplier_info Module</h2>
-        <h3 class="oe_slogan">Categorise supplier product by Supplier name</h3>
-        <div class="oe_span6">
-            <div class="oe_row_img oe_centered">
-                <img src="product_supplier_info.png" class="oe_picture oe_screenshot">
-            </div>
-        </div>
-        <div class="oe_span6">
-            <p class="oe_mt32">This module categorizes each product item by supplier. This allows for users to be able to view a compiled list of products supplied by the supplier. Users can also directly add new products to the supplier's list.&nbsp;</p>
- 				<div class="oe_centeralign oe_websiteonly">
-                <a href="http://www.elico-corp.com"; class="oe_button oe_big oe_tacky">Start your <span class="oe_emph">free</span> trial</a>
-            </div>
+    <div class="oe_row">
+    <h2 class="oe_slogan">product_supplier_info Module</h2> 
+    <h3 class="oe_slogan">Categorise supplier product by Supplier name</h3>
+    <h4 class="oe_slogan"><a href="http://www.openerp.com.cn";>By Elico Corp</a></h4>
+       <p>This module categorizes each product item by supplier.It allows for users to be able to view a compiled list of products supplied by the supplier.  </p>
+               
+                <p>Users can also directly add new products to the supplier's list.</p>
+        <div class="oe_row_img oe_centered oe_mt32">
+            <img class="oe_picture oe_screenshot" src="product_supplier_info.png">
         </div>
     </div>
-</section>
+     <div class="oe_row oe_centeralign oe_more_space">
+            <a href="http://www.elico-corp.com"; class="oe_button oe_big">Start your <span class="oe_emph">free</span> trial</a>
+        </div>
+        <h4 class="oe_slogan">or</h4>
+</section>
\ No newline at end of file

=== modified file 'product_supplier_info/static/description/product_supplier_info.png'
Binary files product_supplier_info/static/description/product_supplier_info.png	2013-08-16 05:31:33 +0000 and product_supplier_info/static/description/product_supplier_info.png	2013-08-23 02:20:58 +0000 differ
=== added directory 'purchase_control_supplier'
=== added file 'purchase_control_supplier/__init__.py'
--- purchase_control_supplier/__init__.py	1970-01-01 00:00:00 +0000
+++ purchase_control_supplier/__init__.py	2013-08-23 02:20:58 +0000
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
+#    Author: Jean LELIEVRE <jean.lelievre@xxxxxxxxxxxxxx>
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import purchase
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file

=== added file 'purchase_control_supplier/__openerp__.py'
--- purchase_control_supplier/__openerp__.py	1970-01-01 00:00:00 +0000
+++ purchase_control_supplier/__openerp__.py	2013-08-23 02:20:58 +0000
@@ -0,0 +1,46 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
+#    Author: Jean LELIEVRE <jean.lelievre@xxxxxxxxxxxxxx>
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+{
+    'name': 'Purchase Control Supplier',
+    'version': '1.0',
+    'category': 'Purchase',
+    'sequence': 19,
+    'summary': 'Purchase Control Supplier',
+    'description': """
+Enables/Disables the supplier control in Purchase.
+    """,
+    'author': 'Elico Corp',
+    'website': 'http://www.elico-corp.com',
+    'images' : [],
+    'depends': ['purchase'],
+    'data': [
+        'purchase_view.xml',
+    ],
+    'test': [],
+    'demo': [],
+    'installable': True,
+    'auto_install': False,
+    'application': False,
+}
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file

=== added directory 'purchase_control_supplier/i18n'
=== added file 'purchase_control_supplier/i18n/zh_CN.po'
--- purchase_control_supplier/i18n/zh_CN.po	1970-01-01 00:00:00 +0000
+++ purchase_control_supplier/i18n/zh_CN.po	2013-08-23 02:20:58 +0000
@@ -0,0 +1,37 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+#	* purchase_control_supplier
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-08-14 09:01+0000\n"
+"PO-Revision-Date: 2013-08-14 09:01+0000\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: purchase_control_supplier
+#: field:res.partner,supplier_product_limit:0
+msgid "Control Supplier Search"
+msgstr "Control Supplier Search"
+
+#. module: purchase_control_supplier
+#: model:ir.model,name:purchase_control_supplier.model_res_partner
+msgid "Partner"
+msgstr "业务伙伴"
+
+#. module: purchase_control_supplier
+#: model:ir.model,name:purchase_control_supplier.model_product_product
+msgid "Product"
+msgstr "产品"
+
+#. module: purchase_control_supplier
+#: help:res.partner,supplier_product_limit:0
+msgid "If checked, allows you to search only the product in this supplier )"
+msgstr "If checked, allows you to search only the product in this supplier )"
+

=== added file 'purchase_control_supplier/purchase.py'
--- purchase_control_supplier/purchase.py	1970-01-01 00:00:00 +0000
+++ purchase_control_supplier/purchase.py	2013-08-23 02:20:58 +0000
@@ -0,0 +1,53 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
+#    Author: Jean LELIEVRE <jean.lelievre@xxxxxxxxxxxxxx>
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import osv, fields
+
+class product_product(osv.osv):
+    _name = "product.product"
+    _inherit = "product.product"
+    
+    def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
+
+        if context and context.get('supplier_id', False):
+            product_limit = self.pool.get('res.partner').read(cr,uid,context['supplier_id'],['supplier_product_limit'])['supplier_product_limit']
+            if product_limit:
+                #    ids = []
+                cr.execute("SELECT distinct(product_id) FROM product_supplierinfo where name = %s" % (context.get('supplier_id')))
+                ids = [x[0] for x in cr.fetchall()]
+                args.append(('id', 'in', ids))
+                order = 'default_code'
+        return super(product_product, self).search(cr, uid, args, offset=offset, limit=limit, order=order, context=context, count=count)
+
+product_product()
+
+class res_partner(osv.osv):
+    _name = 'res.partner'
+    _inherit = 'res.partner'
+
+    _columns = {
+        'supplier_product_limit':fields.boolean("Control Supplier Search", help="""If checked, allows you to search only the product in this supplier )"""),
+    }
+
+    _defaults = {
+        'supplier_product_limit': True,
+    }
\ No newline at end of file

=== added file 'purchase_control_supplier/purchase_view.xml'
--- purchase_control_supplier/purchase_view.xml	1970-01-01 00:00:00 +0000
+++ purchase_control_supplier/purchase_view.xml	2013-08-23 02:20:58 +0000
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+    	
+        <record id="view_partner_form_joomla1" model="ir.ui.view">
+            <field name="name">res.partner.form.FC</field>
+            <field name="model">res.partner</field>
+            <field name="type">form</field>
+            <field name="inherit_id" ref="base.view_partner_form" />
+            <field name="arch" type="xml">
+                <xpath expr="//field[@name='customer']" position="after">
+                    <field name="supplier_product_limit" attrs="{'invisible':[('supplier','!=',True)]}"/>
+                </xpath>
+            </field>
+        </record>
+
+
+
+        <!-- Purchase Order -->
+        <record id="purchase_order_form_fc" model="ir.ui.view">
+            <field name="name">purchase.order.form_FC</field>
+            <field name="model">purchase.order</field>
+            <field name="type">form</field>
+            <field name="inherit_id" ref="purchase.purchase_order_form"/>
+            <field name="arch" type="xml">
+                <xpath expr="//field[@name='order_line']/tree/field['product_id']" position="replace">
+                    
+                            <field name="product_id" on_change="onchange_product_id(parent.pricelist_id,product_id,0,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,context)" context="{'supplier_id': parent.partner_id}"/>
+
+                </xpath>
+            </field>
+        </record>
+    </data>
+</openerp>

=== added directory 'purchase_control_supplier/static'
=== added directory 'purchase_control_supplier/static/description'
=== added file 'purchase_control_supplier/static/description/index.html'
--- purchase_control_supplier/static/description/index.html	1970-01-01 00:00:00 +0000
+++ purchase_control_supplier/static/description/index.html	2013-08-23 02:20:58 +0000
@@ -0,0 +1,20 @@
+<section class="oe_container oe_website_only">
+     
+        <div class="oe_row oe_more_spaced">
+            <h2 class="oe_slogan">purchase_control_supplier Module</h2> 
+            <h3 class="oe_slogan">Filters Product Search in Purchase Orders to Supplier Product List</h3>
+            <h4 class="oe_slogan"><a href="http://www.openerp.com.cn";>By Elico Corp</a></h4>
+            <div class="oe_span6">
+                <p>This module filters the product search in Purchase Orders to only display the products of the Supplier selected which can be added into the current Purchase Order.&nbsp;</p>
+                
+            </div>
+            <div class="oe_span6">
+                <img class="oe_picture" src="purchase_control_supplier.png">
+            </div>
+        </div>
+        <div class="oe_row oe_centeralign oe_more_space">
+            <a href="http://www.elico-corp.com"; class="oe_button oe_big">Start your <span class="oe_emph">free</span> trial</a>
+        </div>
+        <h4 class="oe_slogan">or</h4>
+     
+    </section>
\ No newline at end of file

=== added file 'purchase_control_supplier/static/description/purchase_control_supplier.png'
Binary files purchase_control_supplier/static/description/purchase_control_supplier.png	1970-01-01 00:00:00 +0000 and purchase_control_supplier/static/description/purchase_control_supplier.png	2013-08-23 02:20:58 +0000 differ
=== added directory 'purchase_po_price'
=== added file 'purchase_po_price/__init__.py'
--- purchase_po_price/__init__.py	1970-01-01 00:00:00 +0000
+++ purchase_po_price/__init__.py	2013-08-23 02:20:58 +0000
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
+#    Author: Jean LELIEVRE <jean.lelievre@xxxxxxxxxxxxxx>
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import purchase
\ No newline at end of file

=== added file 'purchase_po_price/__openerp__.py'
--- purchase_po_price/__openerp__.py	1970-01-01 00:00:00 +0000
+++ purchase_po_price/__openerp__.py	2013-08-23 02:20:58 +0000
@@ -0,0 +1,42 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
+#    Author: Jean LELIEVRE <jean.lelievre@xxxxxxxxxxxxxx>
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+{
+    'name': 'Purchase PO Price',
+    'version': '1.0',
+    'category': 'Purchase',
+    'sequence': 19,
+    'summary': 'Purchase PO Price',
+    'description': """ Enable/Disable control on PO Price """,
+    'author': 'Elico Corp',
+    'website': 'http://www.elico-corp.com',
+    'images' : [],
+    'depends': ['purchase'],
+    'data': [
+        'purchase_view.xml',
+    ],
+    'test': [],
+    'demo': [],
+    'installable': True,
+    'auto_install': False,
+    'application': False,
+}
\ No newline at end of file

=== added directory 'purchase_po_price/i18n'
=== added file 'purchase_po_price/i18n/zh_CN.po'
--- purchase_po_price/i18n/zh_CN.po	1970-01-01 00:00:00 +0000
+++ purchase_po_price/i18n/zh_CN.po	2013-08-23 02:20:58 +0000
@@ -0,0 +1,89 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+#	* purchase_po_price
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-08-14 09:02+0000\n"
+"PO-Revision-Date: 2013-08-14 09:02+0000\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: purchase_po_price
+#: code:addons/purchase_po_price/purchase.py:105
+#, python-format
+msgid "You can not modify the price of this product sold by this supplier !"
+msgstr "You can not modify the price of this product sold by this supplier !"
+
+#. module: purchase_po_price
+#: model:ir.model,name:purchase_po_price.model_purchase_order_line
+msgid "Purchase Order Line"
+msgstr "采购订单明细"
+
+#. module: purchase_po_price
+#: field:purchase.order.line,amount_subtotal:0
+msgid "Subtotal(Inc. Tax)"
+msgstr "小计(含税)"
+
+#. module: purchase_po_price
+#: field:purchase.order.line,modify_price:0
+msgid "Modify Price"
+msgstr "修改价格"
+
+#. module: purchase_po_price
+#: field:purchase.order.line,qty_received:0
+msgid "Reception Qty"
+msgstr "已收货数量"
+
+#. module: purchase_po_price
+#: field:purchase.order.line,sequence:0
+msgid "Sequence"
+msgstr "序号"
+
+#. module: purchase_po_price
+#: code:addons/purchase_po_price/purchase.py:105
+#, python-format
+msgid "PO Price"
+msgstr "PO Price"
+
+#. module: purchase_po_price
+#: field:purchase.order.line,qty_unreceived:0
+msgid "Waiting Qty"
+msgstr "待收货数量"
+
+#. module: purchase_po_price
+#: view:purchase.order:0
+msgid "Purchase Order Lines"
+msgstr "采购订单明细"
+
+#. module: purchase_po_price
+#: field:purchase.order.line,price_unit_original:0
+msgid "Original Unit Price"
+msgstr "原始单价"
+
+#. module: purchase_po_price
+#: model:ir.model,name:purchase_po_price.model_res_partner
+msgid "Partner"
+msgstr "业务伙伴"
+
+#. module: purchase_po_price
+#: help:res.partner,po_price_modification_limit:0
+msgid "If checked, allows you to change the price in PO (only when either the Supplier or Product allow it)"
+msgstr "若选择, 允许你在采购上修改单价(在供应商或者产品上设置一个即可)"
+
+#. module: purchase_po_price
+#: help:purchase.order.line,sequence:0
+msgid "Sequence for order in view and print report"
+msgstr "用于视图和报表中的序号"
+
+#. module: purchase_po_price
+#: field:res.partner,po_price_modification_limit:0
+msgid "No control on PO price"
+msgstr "不控采购单价"
+

=== added file 'purchase_po_price/purchase.py'
--- purchase_po_price/purchase.py	1970-01-01 00:00:00 +0000
+++ purchase_po_price/purchase.py	2013-08-23 02:20:58 +0000
@@ -0,0 +1,161 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
+#    Author: Jean LELIEVRE <jean.lelievre@xxxxxxxxxxxxxx>
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import osv, fields
+from tools.translate import _
+import openerp.addons.decimal_precision as dp
+
+class res_partner(osv.osv):
+    _name = 'res.partner'
+    _inherit = 'res.partner'
+
+    _columns = {
+        'po_price_modification_limit':fields.boolean("No control on PO price", help="""If checked, allows you to change the price in PO (only when either the Supplier or Product allow it)"""),
+    }
+
+    _defaults = {
+        'po_price_modification_limit': True,
+    }
+res_partner()
+
+class product_product(osv.osv):
+    _name = "product.product"
+    _inherit = "product.product"
+
+    _columns = {
+        'po_price_modification_limit':fields.boolean("No control on PO price", help="""If checked, allows you to change the price in PO (only when either the Supplier or Product allow it)."""),
+    }
+
+    _defaults = {
+        'po_price_modification_limit': True
+    }
+
+product_product()
+
+class purchase_order_line(osv.osv):
+    _inherit = 'purchase.order.line'
+    
+    _order = 'order_id desc, sequence'
+
+    def _price_unit_line_without_tax(self, cr, uid, ids, prop, arg, context=None):
+        res = {}
+        cur_obj = self.pool.get('res.currency')
+        tax_obj = self.pool.get('account.tax')
+        for line in self.browse(cr, uid, ids, context=context):
+            taxes = tax_obj._unit_compute(cr, uid, line.taxes_id, line.price_unit, product=None, partner=None, quantity=0)
+            cur = line.order_id.pricelist_id.currency_id
+            print taxes and taxes[0] and taxes[0]['amount'] or 0
+            pu_wt = line.price_unit - (taxes and taxes[0] and taxes[0]['amount'] or 0)
+            res[line.id] = cur_obj.round(cr, uid, cur, pu_wt)
+        return res
+
+    def _amount_line_with_tax(self, cr, uid, ids, prop, arg, context=None):
+        res = {}
+        cur_obj = self.pool.get('res.currency')
+        tax_obj = self.pool.get('account.tax')
+        for line in self.browse(cr, uid, ids, context=context):
+            taxes = tax_obj.compute_all(cr, uid, line.taxes_id, line.price_unit, line.product_qty, line.product_id, line.order_id.partner_id, force_excluded=True)
+            cur = line.order_id.pricelist_id.currency_id
+            res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])
+        return res
+    
+    def _qty_received(self, cr, uid, ids, prop, arg, context=None):
+        res = {}
+        for line in self.browse(cr, uid, ids, context=context):
+            qty = 0.0
+            for move in line.move_ids:
+                if move.state == 'done':
+                    qty += move.product_qty
+            res[line.id] = qty
+        return res
+    
+    def _qty_unreceived(self, cr, uid, ids, prop, arg, context=None):
+        res = {}
+        for line in self.browse(cr, uid, ids, context=context):
+            qty = 0.0
+            for move in line.move_ids:
+                if move.state not in ('done', 'cancel'):
+                    qty += move.product_qty
+            res[line.id] = qty
+        return res
+
+    _columns = {
+        'modify_price': fields.boolean('Modify Price'),
+        'sequence': fields.integer('Sequence', help="Sequence for order in view and print report"),
+        'amount_subtotal': fields.function(_amount_line_with_tax, string='Subtotal(Inc. Tax)', type='float', digits_compute=dp.get_precision('Account')),
+        'qty_received': fields.function(_qty_received, string='Reception Qty', type='float', digits_compute=dp.get_precision('Product Unit of Measure')),
+        'qty_unreceived': fields.function(_qty_unreceived, string='Waiting Qty', type='float', digits_compute=dp.get_precision('Product Unit of Measure')),
+        'price_unit_original': fields.float('Original Unit Price', digits_compute=dp.get_precision('Product Price')),
+        'price_unit_exclude_tax': fields.function(_price_unit_line_without_tax, string='Unit Price(Exc. Tax)', type='float', digits_compute=dp.get_precision('Product Price')),
+    }
+    _defaults = {
+        'sequence': 1,
+        'modify_price': False,
+    }    
+
+    
+    def onchange_price_unit(self, cr, uid, ids, partner_id, product_id, price_unit_original, price_unit, context=None):
+        #Not use at the moment! add a readonly attribute in view definition!
+        context = context or {}
+        res = {}
+        
+        if not partner_id and not product_id:
+            return res
+        product = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
+        partner = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context)
+        
+        if not product.po_price_modification_limit and not partner.po_price_modification_limit and price_unit_original != price_unit:
+            res['value'] = {'price_unit': price_unit_original}
+            res['warning'] = {'title' : _('PO Price'), 'message' : _('You can not modify the price of this product sold by this supplier !')}
+            #raise osv.except_osv(_('Error!'), _('You can not modify the price of this product sold by this supplier !'))
+        else:
+            res['value'] = {'price_unit_original':price_unit}
+
+        return res
+
+    def onchange_product_id(self, cr, uid, ids, pricelist_id, product_id, qty, uom_id,
+            partner_id, date_order=False, fiscal_position_id=False, date_planned=False,
+            name=False, price_unit=False, context=None):
+        res = super(purchase_order_line, self).onchange_product_id(cr, uid, ids, pricelist_id, product_id, qty, uom_id,
+            partner_id, date_order=date_order, fiscal_position_id=fiscal_position_id, date_planned=date_planned,
+            name=name, price_unit=price_unit, context=context)
+
+        if not product_id or not partner_id:
+            return res
+
+        res_partner = self.pool.get('res.partner')
+        partner = res_partner.browse(cr, uid, partner_id)
+        product_product = self.pool.get('product.product')
+        product = product_product.browse(cr, uid, product_id, context=context)
+
+        modify_price = not product.po_price_modification_limit and not partner.po_price_modification_limit
+        res['value'].update({'modify_price': modify_price})
+
+        if res and 'value' in res and 'price_unit' in res['value']:
+            print "AAAAAAAAAAAA"
+            res['value'].update({'price_unit_original': res['value']['price_unit']})
+        print "BBBBBBBBBBBBBB%s"%res
+
+        return res
+
+
+purchase_order_line()

=== added file 'purchase_po_price/purchase_view.xml'
--- purchase_po_price/purchase_view.xml	1970-01-01 00:00:00 +0000
+++ purchase_po_price/purchase_view.xml	2013-08-23 02:20:58 +0000
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+
+        <record id="view_partner_form_po_control" model="ir.ui.view">
+            <field name="name">res.partner.form.po.control</field>
+            <field name="model">res.partner</field>
+            <field name="type">form</field>
+            <field name="inherit_id" ref="base.view_partner_form" />
+            <field name="arch" type="xml">
+                <xpath expr="//field[@name='customer']" position="after">
+                    <field name="po_price_modification_limit" attrs="{'invisible':[('supplier','!=',True)]}"/>
+                </xpath>
+            </field>
+        </record>
+
+        <record id="product_normal_form_view_FC" model="ir.ui.view">
+            <field name="name">product.normal.form.FC</field>
+            <field name="model">product.product</field>
+            <field name="type">form</field>
+            <field name="inherit_id" ref="product.product_normal_form_view" />
+            <field name="arch" type="xml">
+                <xpath expr="//field[@name='uom_po_id']" position="after">
+                    <field name="po_price_modification_limit"/>
+                </xpath>
+            </field>
+        </record>
+
+        <!-- Purchase Order -->
+        <record id="purchase_order_form_price_control" model="ir.ui.view">
+            <field name="name">purchase.order.form_price_control</field>
+            <field name="model">purchase.order</field>
+            <field name="type">form</field>
+            <field name="inherit_id" ref="purchase.purchase_order_form"/>
+            <field name="arch" type="xml">
+                <xpath expr="//field[@name='order_line']" position="replace">
+                    <field name="order_line">
+                        <tree string="Purchase Order Lines" editable="bottom">
+
+                            <!-- field name="sequence"/>< by Andy-->
+                            <field name="modify_price" invisible="1"/>
+                            <field name="product_id" on_change="onchange_product_id(parent.pricelist_id,product_id,0,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,context)" context="{'supplier_id': parent.partner_id}"/>
+                            <field name="name"/>
+                            <field name="date_planned"/>
+                            <field name="company_id" groups="base.group_multi_company" widget="selection"/>
+                            <field name="account_analytic_id" groups="purchase.group_analytic_accounting" domain="[('parent_id','!=',False)]"/>
+                            <field name="product_qty" on_change="onchange_product_id(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id,parent.date_order,parent.fiscal_position,date_planned,name,price_unit,context)"/>
+                            <field name="product_uom" groups="product.group_uom" on_change="onchange_product_uom(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,context)"/>
+                            <!--field name="price_unit" attrs="{'readonly':[('modify_price','=',True)]}"/-->
+                            <field name="price_unit_original" invisible="1"/>
+                            <field name="price_unit" on_change="onchange_price_unit(parent.partner_id,product_id,price_unit_original,price_unit,context)"/>
+                            <field name="taxes_id" widget="many2many_tags" domain="[('parent_id','=',False),('type_tax_use','!=','sale')]"/>
+                            <field name="price_unit_exclude_tax"/>
+                            <field name="price_subtotal" invisible="1"/>
+                            <field name="amount_subtotal"/><!-- by Andy-->
+
+                        </tree>
+                    </field>
+                </xpath>
+            </field>
+        </record>
+
+    </data>
+</openerp>

=== added directory 'purchase_po_price/static'
=== added directory 'purchase_po_price/static/description'
=== added file 'purchase_po_price/static/description/index.html'
--- purchase_po_price/static/description/index.html	1970-01-01 00:00:00 +0000
+++ purchase_po_price/static/description/index.html	2013-08-23 02:20:58 +0000
@@ -0,0 +1,20 @@
+<section class="oe_container oe_website_only">
+     
+        <div class="oe_row oe_more_spaced">
+            <h2 class="oe_slogan">puchase_PO_price Module</h2> 
+            <h3 class="oe_slogan">Fixed Product Price to Supplier's Product Price List</h3>
+            <h4 class="oe_slogan"><a href="http://www.openerp.com.cn";>By Elico Corp</a></h4>
+            <div class="oe_span6">
+                <p>This module fixes the product price of the Purchase Quotations Order to the Supplier's Price List. </p>
+                <p>This module disables the modification of the product price in the Purchase Quotations Order.&nbsp;</p>
+            </div>
+            <div class="oe_span6">
+                <img class="oe_picture" src="purchase_PO_price.png">
+            </div>
+        </div>
+        <div class="oe_row oe_centeralign oe_more_space">
+            <a href="http://www.elico-corp.com"; class="oe_button oe_big">Start your <span class="oe_emph">free</span> trial</a>
+        </div>
+        <h4 class="oe_slogan">or</h4>
+    
+            </section>
\ No newline at end of file

=== added file 'purchase_po_price/static/description/purchase_PO_price.png'
Binary files purchase_po_price/static/description/purchase_PO_price.png	1970-01-01 00:00:00 +0000 and purchase_po_price/static/description/purchase_PO_price.png	2013-08-23 02:20:58 +0000 differ
=== added directory 'purchase_price_list_item'
=== added file 'purchase_price_list_item/__init__.py'
--- purchase_price_list_item/__init__.py	1970-01-01 00:00:00 +0000
+++ purchase_price_list_item/__init__.py	2013-08-23 02:20:58 +0000
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
+#    Author: Jean LELIEVRE <jean.lelievre@xxxxxxxxxxxxxx>
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import purchase
\ No newline at end of file

=== added file 'purchase_price_list_item/__openerp__.py'
--- purchase_price_list_item/__openerp__.py	1970-01-01 00:00:00 +0000
+++ purchase_price_list_item/__openerp__.py	2013-08-23 02:20:58 +0000
@@ -0,0 +1,52 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
+#    Author: Jean LELIEVRE <jean.lelievre@xxxxxxxxxxxxxx>
+#            Andy LU<andy.lu@xxxxxxxxxxxxxx>
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+{
+    'name': 'Purchase Price List Item',
+    'version': '1.0',
+    'category': 'Purchase',
+    'sequence': 19,
+    'summary': 'Purchase Price List Item',
+    'description': """ 
+Improve purchase price managment
+================================
+
+    * In Purchase List Item, the price is fixed based on price_surchage if base is 'fixed on UOP'
+    * If 'fixed on UOP', if product UOP change, the price list price will be change automtically.
+    * Add field 'Qty on Hand', and 'Stock Values' for product
+    * Add field 'Qty on Hand', 'Stock Values', UOP in product list view
+
+     """,
+    'author': 'Elico Corp',
+    'website': 'http://www.elico-corp.com',
+    'images' : [],
+    'depends': ['purchase'],
+    'data': [
+             'purchase_view.xml',
+    ],
+    'test': [],
+    'demo': [],
+    'installable': True,
+    'auto_install': False,
+    'application': False,
+}
\ No newline at end of file

=== added directory 'purchase_price_list_item/i18n'
=== added file 'purchase_price_list_item/i18n/purchase_price_list_item.po'
--- purchase_price_list_item/i18n/purchase_price_list_item.po	1970-01-01 00:00:00 +0000
+++ purchase_price_list_item/i18n/purchase_price_list_item.po	2013-08-23 02:20:58 +0000
@@ -0,0 +1,33 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+#	* purchase_price_list_item
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-08-14 09:03+0000\n"
+"PO-Revision-Date: 2013-08-14 09:03+0000\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: purchase_price_list_item
+#: code:addons/purchase_price_list_item/purchase.py:34
+#, python-format
+msgid "Fix Price based on UoP"
+msgstr ""
+
+#. module: purchase_price_list_item
+#: model:ir.model,name:purchase_price_list_item.model_product_pricelist_item
+msgid "Pricelist item"
+msgstr ""
+
+#. module: purchase_price_list_item
+#: field:product.pricelist.item,uom_id:0
+msgid "UoM for Fix Price"
+msgstr ""
+

=== added file 'purchase_price_list_item/purchase.py'
--- purchase_price_list_item/purchase.py	1970-01-01 00:00:00 +0000
+++ purchase_price_list_item/purchase.py	2013-08-23 02:20:58 +0000
@@ -0,0 +1,332 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
+#    Author: Jean LELIEVRE <jean.lelievre@xxxxxxxxxxxxxx>
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import osv, fields
+from tools.translate import _
+
+import openerp.addons.decimal_precision as dp
+
+import time
+from product._common import rounding
+
+
+class product_pricelist_item(osv.osv):
+    _inherit = "product.pricelist.item"
+
+    def _price_field_get(self, cr, uid, context=None):
+        result = super(product_pricelist_item, self)._price_field_get(cr, uid, context=context)
+
+        result.append((-3, _('Fix Price based on UoP')))
+        return result
+
+    _columns = {
+        'base': fields.selection(_price_field_get, 'Based on',required=True, size=-1, help="Base price for computation."),
+        'uom_id': fields.many2one('product.uom','UoM for Fix Price',store=True),
+    }
+    _defaults = {
+        'price_discount': lambda *a: -1,
+        'base': lambda *a: -3,
+    }
+
+    def product_id_change(self,cr,uid,ids,product_id,context=None):
+        if not product_id:
+            return{}
+        prod = self.pool.get('product.product').browse(cr,uid,product_id,context=context)
+
+        if prod.default_code:
+            return {'value': {'name': prod.default_code,'uom_id': prod.uom_po_id.id}}
+        return{}     
+
+    def create(self,cr,uid,vals,context=None):
+        if not vals.get('uom_id',False) and vals.get('product_id', False) and vals.get('base',False) == -3:
+            prod = self.pool.get('product.product').browse(cr,uid,vals.get('product_id',False),context=context)
+            vals['uom_id'] = prod.uom_po_id.id
+
+        return super(product_pricelist_item,self).create(cr,uid,vals,context=context) 
+
+    def write(self, cr, uid, ids, vals, context=None):
+        if type(ids) != type([]):
+            ids = [ids]
+        if not vals.get('uom_id', False) and ids:            
+            pl_item_obj = self.pool.get('product.pricelist.item')
+            for id in ids:
+                item = pl_item_obj.browse(cr, uid, id, context=context)
+                if item.base == -3 and item.product_id:
+                    vals['uom_id'] = item.product_id.uom_po_id.id
+        return super(product_pricelist_item, self).write(cr, uid, ids, vals, context=context) 
+
+product_pricelist_item()
+
+
+class product_pricelist(osv.osv):
+    _inherit = "product.pricelist"
+
+    #def price_get_multi(self, cr, uid, product_ids, context=None):
+    def price_get_multi(self, cr, uid, pricelist_ids, products_by_qty_by_partner, context=None):
+        """multi products 'price_get'.
+           @param pricelist_ids:
+           @param products_by_qty:
+           @param partner:
+           @param context: {
+             'date': Date of the pricelist (%Y-%m-%d),}
+           @return: a dict of dict with product_id as key and a dict 'price by pricelist' as value
+        """
+
+        def _create_parent_category_list(id, lst):
+            if not id:
+                return []
+            parent = product_category_tree.get(id)
+            if parent:
+                lst.append(parent)
+                return _create_parent_category_list(parent, lst)
+            else:
+                return lst
+        # _create_parent_category_list
+
+        if context is None:
+            context = {}
+
+        date = time.strftime('%Y-%m-%d')
+        if 'date' in context:
+            date = context['date']
+
+        currency_obj = self.pool.get('res.currency')
+        product_obj = self.pool.get('product.product')
+        product_category_obj = self.pool.get('product.category')
+        product_uom_obj = self.pool.get('product.uom')
+        supplierinfo_obj = self.pool.get('product.supplierinfo')
+        price_type_obj = self.pool.get('product.price.type')
+
+        # product.pricelist.version:
+        if not pricelist_ids:
+            pricelist_ids = self.pool.get('product.pricelist').search(cr, uid, [], context=context)
+
+        pricelist_version_ids = self.pool.get('product.pricelist.version').search(cr, uid, [
+                                                        ('pricelist_id', 'in', pricelist_ids),
+                                                        '|',
+                                                        ('date_start', '=', False),
+                                                        ('date_start', '<=', date),
+                                                        '|',
+                                                        ('date_end', '=', False),
+                                                        ('date_end', '>=', date),
+                                                    ])
+        if len(pricelist_ids) != len(pricelist_version_ids):
+            raise osv.except_osv(_('Warning!'), _("At least one pricelist has no active version !\nPlease create or activate one."))
+
+        # product.product:
+        product_ids = [i[0] for i in products_by_qty_by_partner]
+        #products = dict([(item['id'], item) for item in product_obj.read(cr, uid, product_ids, ['categ_id', 'product_tmpl_id', 'uos_id', 'uom_id'])])
+        products = product_obj.browse(cr, uid, product_ids, context=context)
+        products_dict = dict([(item.id, item) for item in products])
+
+        # product.category:
+        product_category_ids = product_category_obj.search(cr, uid, [])
+        product_categories = product_category_obj.read(cr, uid, product_category_ids, ['parent_id'])
+        product_category_tree = dict([(item['id'], item['parent_id'][0]) for item in product_categories if item['parent_id']])
+
+        results = {}
+        for product_id, qty, partner in products_by_qty_by_partner:
+            for pricelist_id in pricelist_ids:
+                price = False
+
+                tmpl_id = products_dict[product_id].product_tmpl_id and products_dict[product_id].product_tmpl_id.id or False
+
+                categ_id = products_dict[product_id].categ_id and products_dict[product_id].categ_id.id or False
+                categ_ids = _create_parent_category_list(categ_id, [categ_id])
+                if categ_ids:
+                    categ_where = '(categ_id IN (' + ','.join(map(str, categ_ids)) + '))'
+                else:
+                    categ_where = '(categ_id IS NULL)'
+
+                if partner:
+                    partner_where = 'base <> -2 OR %s IN (SELECT name FROM product_supplierinfo WHERE product_id = %s) '
+                    partner_args = (partner, tmpl_id)
+                else:
+                    partner_where = 'base <> -2 '
+                    partner_args = ()
+
+                #And
+                pl = self.pool.get('product.pricelist').browse(cr, uid, pricelist_id, context=context) 
+                if pl.type == "purchase":
+                    product = products_dict[product_id]
+                    if 'uom' in context:
+                        uom = product.uom_po_id
+                        if uom.id != context['uom']:
+                            qty = qty * product.uom_po_id.factor / product.uom_id.factor
+
+                cr.execute(
+                    'SELECT i.*, pl.currency_id '
+                    'FROM product_pricelist_item AS i, '
+                        'product_pricelist_version AS v, product_pricelist AS pl '
+                    'WHERE (product_tmpl_id IS NULL OR product_tmpl_id = %s) '
+                        'AND (product_id IS NULL OR product_id = %s) '
+                        'AND (' + categ_where + ' OR (categ_id IS NULL)) '
+                        'AND (' + partner_where + ') '
+                        'AND price_version_id = %s '
+                        'AND (min_quantity IS NULL OR min_quantity <= %s) '
+                        'AND i.price_version_id = v.id AND v.pricelist_id = pl.id '
+                    'ORDER BY sequence',
+                    (tmpl_id, product_id) + partner_args + (pricelist_version_ids[0], qty))
+                res1 = cr.dictfetchall()
+                uom_price_already_computed = False
+                for res in res1:
+                    if res:
+                        if res['base'] == -1:
+                            if not res['base_pricelist_id']:
+                                price = 0.0
+                            else:
+                                price_tmp = self.price_get(cr, uid,
+                                        [res['base_pricelist_id']], product_id,
+                                        qty, context=context)[res['base_pricelist_id']]
+                                ptype_src = self.browse(cr, uid, res['base_pricelist_id']).currency_id.id
+                                uom_price_already_computed = True
+                                price = currency_obj.compute(cr, uid, ptype_src, res['currency_id'], price_tmp, round=False)
+                        elif res['base'] == -2:
+                            # this section could be improved by moving the queries outside the loop:
+                            where = []
+                            if partner:
+                                where = [('name', '=', partner) ]
+                            sinfo = supplierinfo_obj.search(cr, uid,
+                                    [('product_id', '=', tmpl_id)] + where)
+                            price = 0.0
+                            if sinfo:
+                                qty_in_product_uom = qty
+                                product_default_uom = product_obj.read(cr, uid, [product_id], ['uom_id'])[0]['uom_id'][0]
+                                supplier = supplierinfo_obj.browse(cr, uid, sinfo, context=context)[0]
+                                seller_uom = supplier.product_uom and supplier.product_uom.id or False
+                                if seller_uom and product_default_uom and product_default_uom != seller_uom:
+                                    uom_price_already_computed = True
+                                    qty_in_product_uom = product_uom_obj._compute_qty(cr, uid, product_default_uom, qty, to_uom_id=seller_uom)
+                                cr.execute('SELECT * ' \
+                                        'FROM pricelist_partnerinfo ' \
+                                        'WHERE suppinfo_id IN %s' \
+                                            'AND min_quantity <= %s ' \
+                                        'ORDER BY min_quantity DESC LIMIT 1', (tuple(sinfo), qty_in_product_uom,))
+                                res2 = cr.dictfetchone()
+                                if res2:
+                                    price = res2['price']
+                        #Add by Andy
+                        elif res['base'] == -3:
+                            price = False
+                        else:
+                            price_type = price_type_obj.browse(cr, uid, int(res['base']))
+                            uom_price_already_computed = True
+                            price = currency_obj.compute(cr, uid,
+                                    price_type.currency_id.id, res['currency_id'],
+                                    product_obj.price_get(cr, uid, [product_id],
+                                    price_type.field, context=context)[product_id], round=False, context=context)
+
+                        if price is not False:
+                            price_limit = price
+                            price = price * (1.0 + (res['price_discount'] or 0.0))
+                            price = rounding(price, res['price_round']) #TOFIX: rounding with tools.float_rouding
+                            price += (res['price_surcharge'] or 0.0)
+                            if res['price_min_margin']:
+                                price = max(price, price_limit + res['price_min_margin'])
+                            if res['price_max_margin']:
+                                price = min(price, price_limit + res['price_max_margin'])
+                            break
+                        #Add by Andy
+                        else:        
+                            if res['base'] == -3:
+                                price = res['price_surcharge'] or 0.0                                    
+                                product = products_dict[product_id]
+                                if 'uom' in context:
+                                    uom = product.uom_po_id
+                                    if uom.id != context['uom']:
+                                        price = product_uom_obj._compute_price(cr, uid, uom.id, price, context['uom'])
+                                uom_price_already_computed = True
+                                #Todo: # Use company currency?
+                                if 'currency_id' in context:                                    
+                                    price = currency_obj.compute(cr, uid, 1,
+                                        context['currency_id'], price, context=context)
+                                if price:
+                                    break
+                    else:
+                        # False means no valid line found ! But we may not raise an
+                        # exception here because it breaks the search
+                        price = False
+
+                if price:
+                    results['item_id'] = res['id']
+                    if 'uom' in context and not uom_price_already_computed:
+                        product = products_dict[product_id]
+                        uom = product.uos_id or product.uom_id
+                        price = product_uom_obj._compute_price(cr, uid, uom.id, price, context['uom'])
+
+                if results.get(product_id):
+                    results[product_id][pricelist_id] = price
+                else:
+                    results[product_id] = {pricelist_id: price}
+
+        return results
+
+product_pricelist()
+
+
+
+class product_product(osv.osv):
+    _name = "product.product"
+    _inherit = "product.product"
+    
+    def _qty_uop(self, cr, uid, ids, name, arg, context=None):
+        res = {}
+        
+        uom_obj = self.pool.get('product.uom')     
+        for id in ids:
+            res.setdefault(id, 0.0)
+        for product in self.browse(cr, uid, ids):
+            res[product.id] = uom_obj._compute_qty(cr, uid, product.uom_id.id, product.qty_available, product.uom_po_id.id)
+        return res
+
+    def _amount_uom(self, cr, uid, ids, name, arg, context=None):
+        res = {}
+
+        for id in ids:
+            res.setdefault(id, 0.0)
+        for product in self.browse(cr, uid, ids):
+            res[product.id] = product.qty_available * product.standard_price
+        return res
+
+    _columns = {
+        #'price_uop': fields.float('Purchase Price(UoP)', digits_compute=dp.get_precision('Product Price')),
+        'qty_uop': fields.function(_qty_uop, type='float', string='Qty on Hand (UoP)', digits_compute=dp.get_precision('Product Unit of Measure')),
+        'amount_uom': fields.function(_amount_uom, type='float', string='Stock Values', digits_compute=dp.get_precision('Account')),
+    }
+    
+    def write(self, cr, uid, ids, vals, context=None):
+        if type(ids) != type([]):
+            ids = [ids]
+        if vals.get('uom_po_id', False) and ids:
+            uom_obj = self.pool.get('product.uom')
+            uop = uom_obj.browse(cr, uid, vals.get('uom_po_id', False), context=context)
+            pl_item_obj = self.pool.get('product.pricelist.item')
+            pl_ids = pl_item_obj.search(cr, uid, [('product_id', '=', ids[0]), ('base', '=', -3)], context=context)
+            for item in pl_item_obj.browse(cr, uid, pl_ids, context=context):
+                if item.uom_id and uop.id == item.uom_id.id:
+                    continue
+                new_price = item.price_surcharge / uop.factor * item.uom_id.factor
+                pl_item_obj.write(cr, uid, [item.id], {'uom_id': vals.get('uom_po_id', False), 'price_surcharge': new_price})
+        
+        return super(product_product, self).write(cr, uid, ids, vals, context=context)    
+
+product_product()
\ No newline at end of file

=== added file 'purchase_price_list_item/purchase_view.xml'
--- purchase_price_list_item/purchase_view.xml	1970-01-01 00:00:00 +0000
+++ purchase_price_list_item/purchase_view.xml	2013-08-23 02:20:58 +0000
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<openerp>
+	<data>
+
+		<record id="product_pricelist_item_list_view_FC" model="ir.ui.view">
+            <field name="name">product.pricelist.item.list.FC</field>
+            <field name="model">product.pricelist.item</field>
+            <field name="inherit_id" ref="product.product_pricelist_item_tree_view" />
+            <field name="arch" type="xml">
+                <xpath expr="//field[@name='categ_id']" position="before">
+                    <field name="price_surcharge" attrs="{'invisible':[('base', '!=', -3)]}"/>
+                    <field name="uom_id" attrs="{'invisible':[('base', '!=', -3)],'readonly':1}"/>
+                </xpath>
+            </field>
+        </record>
+
+        <record id="product_pricelist_item_form_view_FC" model="ir.ui.view">
+            <field name="name">product.pricelist.item.form.FC</field>
+            <field name="model">product.pricelist.item</field>
+            <field name="type">form</field>
+            <field name="inherit_id" ref="product.product_pricelist_item_form_view" />
+            <field name="arch" type="xml">
+                <xpath expr="//field[@name='product_id']" position="replace">
+                    <field name="product_id" on_change="product_id_change(product_id)" attrs="{'required': [('base','=', -3)]}"/>
+                    <field name="uom_id" attrs="{'invisible':[('base', '!=', -3)],'readonly':1}"/>
+                </xpath>
+            </field>
+        </record>
+
+        <record id="product_product_tree_view_uop" model="ir.ui.view">
+            <field name="name">product.product.tree.uop</field>
+            <field name="model">product.product</field>
+            <field name="type">form</field>
+            <field name="inherit_id" ref="product.product_product_tree_view" />
+            <field name="arch" type="xml">
+                <xpath expr="//field[@name='state']" position="before">
+                    <field name="qty_uop"/>
+                    <field name="uom_po_id"/>
+                </xpath>
+                <xpath expr="//field[@name='standard_price']" position="replace">
+                    <field name="standard_price"/>
+                    <field name="amount_uom"/>
+                </xpath>
+            </field>
+        </record>
+
+	</data>
+</openerp>
\ No newline at end of file

=== added directory 'purchase_price_list_item/static'
=== added directory 'purchase_price_list_item/static/description'
=== added file 'purchase_price_list_item/static/description/index.html'
--- purchase_price_list_item/static/description/index.html	1970-01-01 00:00:00 +0000
+++ purchase_price_list_item/static/description/index.html	2013-08-23 02:20:58 +0000
@@ -0,0 +1,18 @@
+<section class="oe_container">
+    <div class="oe_row">
+    <h2 class="oe_slogan">purchase_price_list_item Module</h2> 
+    <h3 class="oe_slogan">Automatically Calculates The Price of Product in Accordance <br>With Its Unit of Measure</h3>
+    <h4 class="oe_slogan"><a href="http://www.openerp.com.cn";>By Elico Corp</a></h4>
+        <p>
+This module automatically calculates the changes in price based on the changes made to the products unit of measure. 
+        </p>
+        <p>In the products list, two additional columns have been added which are Quantity on Hand (Unit of Purchase) and <br>Product's Unit of Measure.</p>
+        <div class="oe_row_img oe_centered oe_mt32">
+            <img class="oe_picture oe_screenshot" src="purchase_price_list_item.png">
+        </div>
+    </div>
+     <div class="oe_row oe_centeralign oe_more_space">
+            <a href="http://www.elico-corp.com"; class="oe_button oe_big">Start your <span class="oe_emph">free</span> trial</a>
+        </div>
+        <h4 class="oe_slogan">or</h4>
+</section>
\ No newline at end of file

=== added file 'purchase_price_list_item/static/description/purchase_price_list_item.png'
Binary files purchase_price_list_item/static/description/purchase_price_list_item.png	1970-01-01 00:00:00 +0000 and purchase_price_list_item/static/description/purchase_price_list_item.png	2013-08-23 02:20:58 +0000 differ

Follow ups