Forráskód Böngészése

[FIX] ajustes vario

Rodney Elpidio Enciso Arias 5 éve
szülő
commit
b040282bf2

+ 1 - 0
__openerp__.py

@@ -20,6 +20,7 @@
     ],
     'data': [
         'views/purchase_order_view.xml',
+        'views/sale_purchase_discount_view.xml',
     ],
     'demo': [
     ],

+ 1 - 1
models/__init__.py

@@ -1,2 +1,2 @@
 import purchase_order
-# import sale_fast_confirm
+import sale_purchase_discount

+ 29 - 0
models/sale_purchase_discount.py

@@ -0,0 +1,29 @@
+# -*- encoding: utf-8 -*-
+from openerp import models, api, fields
+from pytz import timezone
+from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT, DEFAULT_SERVER_DATE_FORMAT
+from datetime import datetime,timedelta
+
+DATE_FORMAT = '%Y-%m-%d'
+
+class SalePurchaseDiscount(models.Model):
+    _name = 'sale.purchase.discount'
+
+    name = fields.Char('Nombre')
+    value = fields.Float(string='Valor',default=0.0)
+    type = fields.Selection([('sale','Ventas'),('purchase','Compras')],'Tipo de descuento')
+
+class PurchaseOrderLine(models.Model):
+    _inherit = 'purchase.order.line'
+    _name = 'purchase.order.line'
+
+    discount_id = fields.Many2one(
+        'sale.purchase.discount',
+        string='Descuento',
+        ondelete='restrict'
+    )
+
+    @api.onchange('discount_id')
+    def _calculate_purchase_discount(self):
+        for line in self:
+            line.discount = line.discount_id.value

+ 3 - 8
views/purchase_order_view.xml

@@ -32,14 +32,9 @@
                 <xpath expr="//tree[@string='Purchase Order Lines']//field[@name='product_uom']" position="attributes">
                     <attribute name="string">Unidad de Medida</attribute>
                 </xpath>
-            </field>
-        </record>
-
-        <record id="view_purchase_confirm_form" model="ir.ui.view">
-            <field name="name">purchase.order.form - Confirm</field>
-            <field name="model">purchase.order</field>
-            <field name="inherit_id" ref="purchase.purchase_order_form"/>
-            <field name="arch" type="xml">
+                <!--
+                    BUTTONS
+                -->
                 <button name="bid_received" states="sent" position="after">
                     <button name="purchase_process_now" string="Procesar Compra" type="object" states="draft,sent" groups="base.group_user" class="oe_highlight"/>
                 </button>

+ 87 - 0
views/sale_purchase_discount_view.xml

@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <record id="sale_purchase_discount_search_form_view" model="ir.ui.view">
+           <field name="name">sale.purchase.discount.search.form</field>
+           <field name="model">sale.purchase.discount</field>
+           <field name="arch" type="xml">
+                <search string="Sale Purchase Discount">
+                    <field name="name"/>
+                    <field name="type"/>
+                </search>
+           </field>
+        </record>
+
+        <record id="sale_purchase_discount_form_view" model="ir.ui.view">
+            <field name="name">sale.purchase.discount.form</field>
+            <field name="model">sale.purchase.discount</field>
+            <field name="arch" type="xml">
+                <form string="Sale Purchase Discount" version="7.0">
+                    <sheet>
+                        <div class="oe_title">
+                            <div class="oe_edit_only">
+                                <label for="name" string="Nombre del descuento"/>
+                            </div>
+                            <h1>
+                                <field name="name"/>
+                            </h1>
+                        </div>
+                        <group>
+                            <field name="value"/>
+                            <field name="type"/>
+                        </group>
+                    </sheet>
+                </form>
+            </field>
+        </record>
+
+        <record id="sale_purchase_discount_tree_view" model="ir.ui.view">
+            <field name="name">sale.purchase.discount.tree</field>
+            <field name="model">sale.purchase.discount</field>
+            <field name="arch" type="xml">
+                <tree string="Sale Purchase Discount">
+                    <field name="name"/>
+                    <field name="value"/>
+                    <field name="type"/>
+                </tree>
+            </field>
+        </record>
+
+        <record model="ir.actions.act_window" id="action_sale_purchase_discount">
+            <field name="name">Sale Purchase Discount</field>
+            <field name="res_model">sale.purchase.discount</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,form</field>
+        </record>
+
+        <menuitem
+            name="Configurar Descuentos"
+            id="menu_sale_purchase_discount_parent"
+            parent="purchase.menu_purchase_config_purchase"/>
+
+        <menuitem
+            name="Descuentos"
+            id="menu_purchase_discount"
+            action="action_sale_purchase_discount"
+            parent="menu_sale_purchase_discount_parent"/>
+
+
+        <!--
+            PURCHASE ORDER
+        -->
+        <record id="purchase_line_discount_form" model="ir.ui.view">
+            <field name="name">purchase.order.form - Confirm</field>
+            <field name="model">purchase.order</field>
+            <field name="inherit_id" ref="purchase.purchase_order_form"/>
+            <field name="arch" type="xml">
+                <xpath expr="//tree[@string='Purchase Order Lines']//field[@name='discount']" position="before">
+                    <field name="discount_id" domain="[('type','=','purchase')]"/>
+                </xpath>
+                <xpath expr="//tree[@string='Purchase Order Lines']//field[@name='discount']" position="attributes">
+                    <attribute name="invisible">1</attribute>
+                </xpath>
+            </field>
+        </record>
+
+    </data>
+</openerp>