Commits

Raimon Esteve (Zikzakmedia) committed c7ca2c9

Sale shop by company

  • Participants
  • Parent commits ec58138

Comments (0)

Files changed (4)

 Version 2.6.0 - 2012-10-08
 * Simplify module information with python configuration
 * Active Record
+* Sale shop by company
 
 Version 2.4.0 - 2012-06-26
 * Initial release
                     'have permission to edit edit in this shop.',
             })
 
-    @staticmethod
-    def default_shop():
-        User = Pool().get('res.user')
-        user = User(Transaction().user)
-
-        return user.shop and user.shop.id or False
-
     def on_change_party(self):
         User = Pool().get('res.user')
         Shop = Pool().get('sale.shop')
         return res
 
     @staticmethod
+    def default_company():
+        User = Pool().get('res.user')
+        user = User(Transaction().user)
+        return user.shop and user.shop.company.id or Transaction().context.get('company')
+
+    @staticmethod
+    def default_shop():
+        User = Pool().get('res.user')
+        user = User(Transaction().user)
+        return user.shop and user.shop.id or False
+
+    @staticmethod
     def default_invoice_method():
         User = Pool().get('res.user')
         user = User(Transaction().user)
 
 from trytond.model import ModelView, ModelSQL, fields
 from trytond.pool import Pool
-from trytond.pyson import Eval, Bool
+from trytond.pyson import If, Eval, Bool
+from trytond.transaction import Transaction
 
 __all__ = ['SaleShop', 'SaleShopResUser']
 
                 ], 'Sale Shipment Method', states={
                 'required': Bool(Eval('context', {}).get('company', 0)),
                 }))
+    company = fields.Many2One('company.company', 'Company', required=True,
+        domain=[
+            ('id', If(Eval('context', {}).contains('company'), '=', '!='),
+                Eval('context', {}).get('company', 0)),
+            ], select=True)
 
+    @staticmethod
+    def default_company():
+        return Transaction().context.get('company')
 
 class SaleShopResUser(ModelSQL):
     'Sale Shop - Res User'
             <field name="type">form</field>
             <field name="arch" type="xml">
                 <![CDATA[
-                <form string="Shops" col="6">
+                <form string="Shops" col="4">
                     <label name="name"/>
                     <field name="name"/>
-                    <notebook colspan="6">
+                    <label name="company"/>
+                    <field name="company"/>
+                    <notebook colspan="4">
                         <page string="General" id="general">
                             <label name="sale_sequence"/>
                             <field name="sale_sequence" widget="selection"/>
                     <field name="name"/>
                     <field name="warehouse"/>
                     <field name="price_list"/>
+                    <field name="company"/>
                 </tree>
                 ]]>
             </field>