Пример #1
0
class ResPartner(osv.Model):
    _inherit = 'res.partner'

    def _supplier_customer_advance_get(self, cr, uid, ids, field, arg,
                                       context=None):
        res = {}
        for record_id in ids:
            res = {record_id: {'customer_advance': 0.0,
                               'supplier_advance': 0.0}}
        return res

    _columns = {
        'property_account_supplier_advance': fields.property(
            type='many2one',
            relation='account.account',
            string="Account Supplier Advance",
            domain="[('type','=','payable')]",
            help="This account will be used for advance payment of suppliers"),
        'property_account_customer_advance': fields.property(
            type='many2one',
            relation='account.account',
            string="Account Customer Advance",
            domain="[('type','=','receivable')]",
            help="This account will be used for advance payment of custom"),
        #        'customer_advance': fields.function(
        #            _supplier_customer_advance_get,
        #            type='float',
        #            string='Total Customer Advance',
        #            multi='sc',
        #            help="Total amount of advance payment of custom."),
        #        'supplier_advance': fields.function(
        #            _supplier_customer_advance_get,
        #            type='float',
        #            string='Total Supplier Advance',
        #            multi='sc',
        #            help="Total amount of advance payment of suppliers."),
    }
Пример #2
0
class product_category(osv.osv):
    _inherit = 'product.category'
    _columns = {
        'property_valuation': fields.property(
            type='selection',
            selection=[('manual_periodic', 'Periodic (manual)'),
                       ('real_time', 'Perpetual (automated)')],
            string='Inventory Valuation',
            required=True, copy=True,
            help="If perpetual valuation is enabled for a product, the system "
                 "will automatically create journal entries corresponding to "
                 "stock moves, with product price as specified by the 'Costing "
                 "Method'. The inventory variation account set on the product "
                 "category will represent the current inventory value, and the "
                 "stock input and stock output account will hold the counterpart "
                 "moves for incoming and outgoing products."),
        'property_cost_method': fields.property(
            type='selection',
            selection=[('standard', 'Standard Price'),
                       ('average', 'Average Price'),
                       ('real', 'Real Price')],
            string="Costing Method",
            required=True, copy=True,
            help="Standard Price: The cost price is manually updated at the end "
                 "of a specific period (usually once a year).\nAverage Price: "
                 "The cost price is recomputed at each incoming shipment and "
                 "used for the product valuation.\nReal Price: The cost price "
                 "displayed is the price of the last outgoing product (will be "
                 "used in case of inventory loss for example)."""),
        'property_stock_journal': fields.property(
            relation='account.journal',
            type='many2one',
            string='Stock Journal',
            help="When doing real-time inventory valuation, this is the Accounting Journal in which entries will be automatically posted when stock moves are processed."),
        'property_stock_account_input_categ_id': fields.property(
            type='many2one',
            relation='account.account',
            string='Stock Input Account',
            domain=[('deprecated', '=', False)], oldname="property_stock_account_input_categ",
            help="When doing real-time inventory valuation, counterpart journal items for all incoming stock moves will be posted in this account, unless "
                 "there is a specific valuation account set on the source location. This is the default value for all products in this category. It "
                 "can also directly be set on each product"),
        'property_stock_account_output_categ_id': fields.property(
            type='many2one',
            relation='account.account',
            domain=[('deprecated', '=', False)],
            string='Stock Output Account', oldname="property_stock_account_output_categ",
            help="When doing real-time inventory valuation, counterpart journal items for all outgoing stock moves will be posted in this account, unless "
                 "there is a specific valuation account set on the destination location. This is the default value for all products in this category. It "
                 "can also directly be set on each product"),
        'property_stock_valuation_account_id': fields.property(
            type='many2one',
            relation='account.account',
            string="Stock Valuation Account",
            domain=[('deprecated', '=', False)],
            help="When real-time inventory valuation is enabled on a product, this account will hold the current value of the products.",),
    }
Пример #3
0
class ups_account_shipping(osv.osv):
    
    _name = "ups.account.shipping"

    _columns = {
        'name': fields.char('Name', size=64, required=True),
        'ups_account_id': fields.many2one('ups.account', 'UPS Account', required=True),
        'accesslicensenumber': fields.related('ups_account_id', 'accesslicensenumber', type='char', size=64, string='AccessLicenseNumber', required=True),
        'userid': fields.related('ups_account_id', 'userid', type='char', size=64, string='UserId', required=True),
        'password': fields.related('ups_account_id', 'password', type='char', size=64, string='Password', required=True),
        'active': fields.related('ups_account_id', 'ups_active', string='Active', type='boolean'),
        'acc_no': fields.related('ups_account_id', 'acc_no', type='char', size=64, string='Account Number', required=True),
        'atten_name': fields.char('AttentionName', size=64, required=True, select=1),
        'tax_id_no': fields.char('Tax Identification Number', size=64 , select=1, help="Shipper's Tax Identification Number."),
        'logistic_company_id': fields.many2one('logistic.company', 'Parent Logistic Company'),
#         'ups_shipping_service_ids': fields.one2many('ups.shipping.service.type', 'ups_account_id', 'Shipping Service'),
        'ups_shipping_service_ids':fields.many2many('ups.shipping.service.type', 'shipping_service_rel', 'ups_account_id', 'service_id', 'Shipping Service'),
        'address': fields.property(
           'res.partner',
           type='many2one',
           relation='res.partner',
           string="Shipper Address",
           view_load=True),
        'trademark': fields.char('Trademark', size=1024, select=1),
        'company_id': fields.many2one('res.company', 'Company'),
    }
    _defaults = {
        'active': True
    }
    
    def onchange_ups_account(self, cr, uid, ids, ups_account_id=False, context=None):
        res = {
            'accesslicensenumber': '',
            'userid': '',
            'password': '',
            'active': True,
            'acc_no': ''
            }
        
        if ups_account_id:
            ups_account = self.pool.get('ups.account').browse(cr, uid, ups_account_id, context=context)
            res = {
                'accesslicensenumber': ups_account.accesslicensenumber,
                'userid': ups_account.userid,
                'password': ups_account.password,
                'active': ups_account.ups_active,
                'acc_no': ups_account.acc_no
                }
        return {'value': res}
Пример #4
0
class l10n_pe_4ta_suspension(osv.Model):
    _name = "l10n_pe_4ta.suspension"
    _columns = {
        'partner_id':
        fields.many2one('res.partner', string="Partner", required=True),
        'property_fiscalyear_id':
        fields.property(type='many2one',
                        relation='account.fiscalyear',
                        string="fiscal Year",
                        required=True),
        'name':
        fields.char('Order Number', 16),
        'application_result':
        fields.selection([('valid', 'Valid'), ('invalid', 'Invalid')],
                         string='Application Result',
                         required=True),
        'application_date':
        fields.date('Application Date'),
        'application_end':
        fields.date('Application End'),
    }
    _defaults = {
        'application_result':
        'valid',
        'application_date':
        lambda *a: time.strftime('%Y-%m-%d'),
        'property_fiscalyear_id':
        lambda s, cr, u, c: s.pool.get('account.fiscalyear').find(
            cr, u, context=c),
        'application_end':
        lambda s, cr, u, c: s.pool.get('account.fiscalyear').browse(
            cr,
            u,
            s.pool.get('account.fiscalyear').find(cr, u, context=c),
            context=c).date_stop,
    }
    _sql_constraints = [('partner_name_uniq', 'unique(partner_id,name)',
                         'Partner and order number must be unique!')]

    def name_get(self, cr, uid, ids, context=None):
        if not ids:
            return []
        if context is None: context = {}
        return [
            (r['id'],
             (str("[%s%s] %s" % (r.property_fiscalyear_id.name, r.name and
                                 (' - ' + r.name) or '', r.partner_id.name))
              or '')) for r in self.browse(cr, uid, ids, context=context)
        ]
Пример #5
0
class res_partner(osv.osv):
    _inherit = "res.partner"
    _columns = {
        'x_spese_id':
        fields.many2one('res.x.spese', 'Spese', required=False),
        'x_data_dec':
        fields.datetime('Data decorrenza fatture', required=False),
        'x_payment_term_dec':
        fields.property('account.payment.term',
                        type='many2one',
                        relation='account.payment.term',
                        string='Termine di pagamento  su decorecorrenza',
                        view_load=True,
                        help="Termine di pagamento  su decorecorrenza"),
    }
Пример #6
0
class account_asset_location(osv.Model):
    """ Add Property Field In order to Complete Convert the Assets """

    _inherit = 'account.asset.location'
    _columns = {
        'property_customer_location':
        fields.property(
            'stock.location',
            type='many2one',
            relation='stock.location',
            string="Customer Location",
            view_load=True,
            domain=[('usage', '=', 'customer')],
        ),
    }
Пример #7
0
class res_partner(osv.Model):
    """
    Inherit partner model to make property_accounts not required
    """
    _inherit = 'res.partner'

    _columns = {
        'property_account_payable': fields.property(
            'account.account',
            type='many2one',
            relation='account.account',
            string="Account Payable",
            view_load=True,
            domain="[('type', '=', 'payable')]",
            help="This account will be used instead of the default one as the payable account for the current partner"),
        'property_account_receivable': fields.property(
            'account.account',
            type='many2one',
            relation='account.account',
            string="Account Receivable",
            view_load=True,
            domain="[('type', '=', 'receivable')]",
            help="This account will be used instead of the default one as the receivable account for the current partner"),
    }
Пример #8
0
class res_partner(osv.Model):

    _inherit = 'res.partner'

    _columns = {
        'property_payment_term_p_suppliers':
        fields.property(
            'payment.terms.partner',
            type='many2one',
            relation='payment.terms.partner',
            string='Payment Term Supplier',
            view_load=True,
            help="This payment term will be used instead of the default one "
            "for purchase orders and supplier invoices"),
        'property_payment_term_p_customer':
        fields.property(
            'payment.terms.partner',
            type='many2one',
            relation='payment.terms.partner',
            view_load=True,
            string='Payment Term Customer',
            help="This payment term will be used instead of the default one "
            "for sale orders and customer invoices"),
    }
Пример #9
0
class product_template(osv.osv):
    _inherit = "product.template"
    _columns = {
        'taxes_id':
        fields.many2many('account.tax',
                         'product_taxes_rel',
                         'prod_id',
                         'tax_id',
                         'Customer Taxes',
                         domain=[('parent_id', '=', False),
                                 ('type_tax_use', 'in', ['sale', 'all'])]),
        'supplier_taxes_id':
        fields.many2many('account.tax',
                         'product_supplier_taxes_rel',
                         'prod_id',
                         'tax_id',
                         'Supplier Taxes',
                         domain=[('parent_id', '=', False),
                                 ('type_tax_use', 'in', ['purchase', 'all'])]),
        'property_account_income':
        fields.property(
            type='many2one',
            relation='account.account',
            string="Income Account",
            help=
            "This account will be used for invoices instead of the default one to value sales for the current product."
        ),
        'property_account_expense':
        fields.property(
            type='many2one',
            relation='account.account',
            string="Expense Account",
            help=
            "This account will be used for invoices instead of the default one to value expenses for the current product."
        ),
    }
Пример #10
0
class res_partner(osv.osv):
    _inherit = 'res.partner'
    _columns = {
        'property_invoice_type': fields.property(
            'sale_journal.invoice.type',
            type = 'many2one',
            relation = 'sale_journal.invoice.type',
            string = "Invoicing Type",
            view_load = True,
            group_name = "Accounting Properties",
            help = "This invoicing type will be used, by default, to invoice the current partner."),
    }

    def _commercial_fields(self, cr, uid, context=None):
        return super(res_partner, self)._commercial_fields(cr, uid, context=context) + ['property_invoice_type']
Пример #11
0
class res_users(osv.osv):
    _inherit = 'res.users'
    _columns = {
        'commission_id':
        fields.many2one('sale.commission.term', 'Commission Rate'),
        'property_account_payable_user':
        fields.property(type='many2one',
                        relation='account.account',
                        string="Payable Account",
                        help="This account will be used to record Payable"),
        'property_account_commission_user':
        fields.property(
            type='many2one',
            relation='account.account',
            string="Commission Account",
            help="This account will be used to record commissions"),
    }

    def write(self, cr, uid, ids, vals, context=None):
        resp = super(res_users, self).write(cr, uid, ids, vals, context)
        for user in self.browse(cr, uid, ids):
            pass

        return resp
Пример #12
0
class product_commission(osv.osv):

    _name = "commission_product.commission"
    _description = "Commission"
    _rec_name = "product_id"
    _columns = {
        "product_id":
        fields.many2one("product.product",
                        "Product",
                        required=True,
                        select=True),
        "partner_id":
        fields.many2one("res.partner", "Partner", required=True),
        "commission_percent":
        fields.float("Commission %"),
        "property_commission_product":
        fields.property(type="many2one",
                        relation="product.product",
                        string="Invoice Product"),
        "property_analytic_journal":
        fields.property(type="many2one",
                        relation="account.analytic.journal",
                        string="Commission Journal")
    }
Пример #13
0
class product_template(osv.osv):
    _inherit = "product.template"

    _columns = {
        'standard_price':
        fields.property(
            type='float',
            digits_compute=dp.get_precision('Product Purchase Price'),
            help='Cost price of the product template used for standard stock '
            'valuation in accounting and used as a base price on purchase '
            'orders. Expressed in the default unit of measure of the '
            'product.',
            groups="base.group_user",
            string="Cost Price"),
    }
Пример #14
0
class product_product(osv.osv):
    
    _inherit = 'product.product'

    _columns = {
        'property_expense_input_vat_tax': fields.property(
            'account.tax',
            type='many2one',
            relation='account.tax',
            string="Expense Input VAT Tax",
            view_load=True,
            domain="[('type_tax_use', '=', 'purchase')]",
            help="This Tax and its Account Code will be used in HR Expense Line, when VAT is identified.",
            required=True,
            readonly=True),
        'property_expense_personal_wht_tax': fields.property(
            'account.tax',
            type='many2one',
            relation='account.tax',
            string="Expense Personal WHT Tax",
            view_load=True,
            domain="[('type_tax_use', '=', 'purchase')]",
            help="This Tax and its Account Code will be used in HR Expense Line, when Supplier Type is Personal and WHT is identified.",
            required=True,
            readonly=True),
        'property_expense_company_wht_tax': fields.property(
            'account.tax',
            type='many2one',
            relation='account.tax',
            string="Expense Company WHT Tax",
            view_load=True,
            domain="[('type_tax_use', '=', 'purchase')]",
            help="This Tax and its Account Code will be used in HR Expense Line, when Supplier Type is Company and WHT is identified.",
            required=True,
            readonly=True),                       
    }
Пример #15
0
class res_partner(orm.Model):
    _name = "res.partner"
    _inherit = "res.partner"

    _columns = {
        'fal_project_id':
        fields.property(type='many2one',
                        relation='account.analytic.account',
                        string='Project',
                        view_load=True,
                        ondelete='set null'),
    }


#end of res_partner()
Пример #16
0
class product_category(osv.osv):
    _inherit = "product.category"
    _columns = {
        'property_account_income_refund_categ':
        fields.property(
            'account.account',
            type='many2one',
            relation='account.account',
            string="Cuenta categoria nota de credito de gastos",
            view_load=True,
            help=
            "Esta cuenta se utiliza para cuando se aplican notas de credito de cliente."
        ),
        'property_account_expense_refund_categ':
        fields.property(
            'account.account',
            type='many2one',
            relation='account.account',
            string="Cuenta de la categoria notas de creditos de ingresos",
            view_load=True,
            help=
            "Esta cuenta se utiliza cuando se generan notas de credito de proveedor."
        ),
    }
Пример #17
0
class product_template(osv.osv):
    _inherit = "product.template"
    _columns = {
        'property_account_creditor_price_difference':
        fields.property(
            'account.account',
            type='many2one',
            relation='account.account',
            string="Price Difference Account",
            view_load=True,
            help=
            "This account will be used to value price difference between purchase price and cost price."
        ),

        #Redefine fields to change help text for anglo saxon methodology.
        'property_account_income':
        fields.property(
            'account.account',
            type='many2one',
            relation='account.account',
            string="Income Account",
            view_load=True,
            help=
            "This account will be used to value outgoing stock using sale price."
        ),
        'property_account_expense':
        fields.property(
            'account.account',
            type='many2one',
            relation='account.account',
            string="Expense Account",
            view_load=True,
            help=
            "This account will be used to value outgoing stock using cost price."
        ),
    }
Пример #18
0
class res_partner(osv.osv):
    _inherit = 'res.partner'
    _columns = {
        'property_wh_munici_payable':
        fields.property(
            'account.account',
            type='many2one',
            relation='account.account',
            string="Purchase local withholding account",
            method=True,
            view_load=True,
            domain="[('type', '=', 'other')]",
            help="This account will be used debit local withholding amount"),
        'property_wh_munici_receivable':
        fields.property(
            'account.account',
            type='many2one',
            relation='account.account',
            string="Sale local withholding account",
            method=True,
            view_load=True,
            domain="[('type', '=', 'other')]",
            help="This account will be used credit local withholding amount"),
    }
Пример #19
0
class res_partner(osv.osv):
    _inherit = 'res.partner'
    _columns = {
        'property_stock_customer':
        fields.property(
            'stock.location',
            type='many2one',
            relation='stock.location',
            string="Customer Location",
            view_load=True,
            help=
            "This stock location will be used, instead of the default one, as the destination location for goods you send to this partner"
        ),
        'property_stock_supplier':
        fields.property(
            'stock.location',
            type='many2one',
            relation='stock.location',
            string="Supplier Location",
            view_load=True,
            help=
            "This stock location will be used, instead of the default one, as the source location for goods you receive from the current partner"
        ),
    }
Пример #20
0
class res_partner(orm.Model):
    _inherit = 'res.partner'
    _columns = {
        'product_ids':
        fields.one2many('partner.product', 'partner_id', 'Price list'),
        'property_product_pricelist_indirect_invoicing':
        fields.property(
            type='many2one',
            relation='product.pricelist',
            domain=[('type', '=', 'sale')],
            string="Sale Pricelist (Indirect Invoicing)",
            help=
            "This pricelist will be used, instead of the default one, for indirect sales invoicing to the current partner"
        ),
    }
Пример #21
0
class fedex_account_shipping(osv.osv):
    _name = "fedex.account.shipping"
    _columns = {
        'name': fields.char('Name', size=64, required=True),
        'fedex_account_id': fields.many2one('fedex.account', 'FedEx Account', required=True),
        'integrator_id': fields.related('fedex_account_id', 'fedex_integrator_id', type='char', size=64, string='IntegratorID', required=True),
        'password': fields.related('fedex_account_id', 'fedex_password', type='char', size=64, string='Password', required=True),
        'active': fields.boolean('Active'),
        'key': fields.related('fedex_account_id', 'fedex_key', type='char', size=64, string='Key', required=True),
        'account_number': fields.related('fedex_account_id', 'fedex_account_number', type='char', size=64, string='Account Number', required=True),
        'meter_number': fields.related('fedex_account_id', 'fedex_meter_number', type='char', size=64, string='Meter Number', required=True),
        'tax_id_no': fields.char('Tax Identification Number', size=64 , select=1, help="Shipper's Tax Identification Number."),
        'logistic_company_id': fields.many2one('logistic.company', 'Parent Logistic Company'),
        'company_id': fields.dummy(string='Company ID', relation='res.company', type='many2one'), # For playing nice with the global domain.
        'address': fields.property(
           'res.partner',
           type='many2one',
           relation='res.partner',
           string="Shipper Address",
           view_load=True),
        'sandbox': fields.boolean('Sandbox mode')
    }
    _defaults = {
        'active': True,
        'sandbox': False
    }

    def onchange_fedex_account(self, cr, uid, ids, fedex_account_id=False, context=None):
        res = {
            'key': '',
            'integrator_id': '',
            'password': '',
            'account_number': '',
            'meter_number': '',
            'sandbox': True
        }

        if fedex_account_id:
            fedex_account = self.pool.get('fedex.account').browse(cr, uid, fedex_account_id, context=context)
            res = {
                'key': fedex_account.fedex_key,
                'integrator_id': fedex_account.fedex_integrator_id,
                'password': fedex_account.fedex_password,
                'account_number': fedex_account.fedex_account_number,
                'meter_number': fedex_account.fedex_meter_number,
                'sandbox': fedex_account.test_mode
            }
        return {'value': res}
Пример #22
0
class l10n_br_account_fiscal_category(orm.Model):
    _name = 'l10n_br_account.fiscal.category'
    _description = 'Categoria Fiscail'
    _columns = {
        'code':
        fields.char(u'Código', size=254, required=True),
        'name':
        fields.char(u'Descrição', size=254),
        'type':
        fields.selection([('input', 'Entrada'), ('output', u'Saída')], 'Tipo'),
        'property_journal':
        fields.property(
            'account.journal',
            type='many2one',
            relation='account.journal',
            string=u"Diário Contábil",
            method=True,
            view_load=True,
            help=u"Diário utilizado para esta categoria de operação fiscal"),
        'fiscal_type':
        fields.selection([('product', 'Produto'), ('service', u'Serviço')],
                         'Tipo Fiscal',
                         required=True),
        'journal_type':
        fields.selection([('sale', 'Venda'),
                          ('sale_refund', u'Devolução de Venda'),
                          ('purchase', 'Compras'),
                          ('purchase_refund', u'Devolução de Compras')],
                         u'Tipo do Diário',
                         size=32,
                         required=True),
        'refund_fiscal_category_id':
        fields.many2one(
            'l10n_br_account.fiscal.category',
            u'Categoria Fiscal de Devolução',
            domain="[('type', '!=', type), ('fiscal_type', '=', fiscal_type), "
            "('journal_type', 'like', journal_type)]"),
        'fiscal_position_ids':
        fields.one2many('account.fiscal.position', 'fiscal_category_id',
                        u'Posições Fiscais'),
        'note':
        fields.text(u'Observações')
    }
    _defaults = {
        'type': 'output',
        'fiscal_type': 'product',
        'journal_type': 'sale'
    }
Пример #23
0
class product_product(orm.Model):
    _name = "product.product"
    _inherit = "product.product"
    
    _columns = {
        'project_id': fields.property(
            type='many2one',
            relation='account.analytic.account',
            string='Project', 
            view_load=True,
            ondelete='set null'),
        'customer_code' : fields.char('Customer Code',size=128),
        'customer_ref_number' : fields.char('Customer Reference Number',size=128),
    }

#end of product_product()
Пример #24
0
class ProductProduct(orm.Model):
    _inherit = 'product.product'

    _columns = {
        'standard_price':
        fields.property('product.product',
                        type='float',
                        digits_compute=dp.get_precision('Product Price'),
                        string='Standard Price',
                        method=True,
                        view_load=True,
                        required=True,
                        readonly=True,
                        help="Product's cost for accounting stock valuation. "
                        "It is the base price for the supplier price."),
    }
Пример #25
0
class res_partner(osv.osv):
    _name = 'res.partner'
    _inherit = 'res.partner'
    _columns = {
        'property_product_pricelist':
        fields.property(
            'product.pricelist',
            type='many2one',
            relation='product.pricelist',
            domain=[('type', '=', 'sale')],
            string="Sale Pricelist",
            view_load=True,
            help=
            "This pricelist will be used, instead of the default one, for sales to the current partner"
        ),
    }
Пример #26
0
    def test_1_property_multicompany(self):
        cr, uid = self.cr, self.uid

        parent_company_id = self.imd.get_object_reference(cr, uid, 'base', 'main_company')[1]
        country_be = self.imd.get_object_reference(cr, uid, 'base', 'be')[1]
        country_fr = self.imd.get_object_reference(cr, uid, 'base', 'fr')[1]
        group_partner_manager = self.imd.get_object_reference(cr, uid, 'base', 'group_partner_manager')[1]
        group_multi_company = self.imd.get_object_reference(cr, uid, 'base', 'group_multi_company')[1]

        sub_company = self.company.create(cr, uid, {'name': 'MegaCorp', 'parent_id': parent_company_id})
        alice = self.user.create(cr, uid, {'name': 'Alice',
            'login':'******',
            'email':'*****@*****.**',
            'company_id':parent_company_id,
            'company_ids':[(6, 0, [parent_company_id, sub_company])],
            'country_id':country_be,
            'groups_id': [(6, 0, [group_partner_manager, group_multi_company])]
        })
        bob = self.user.create(cr, uid, {'name': 'Bob',
            'login':'******',
            'email':'*****@*****.**',
            'company_id':sub_company,
            'company_ids':[(6, 0, [parent_company_id, sub_company])],
            'country_id':country_fr,
            'groups_id': [(6, 0, [group_partner_manager, group_multi_company])]
        })
        
        self.partner._columns = dict(self.partner._columns)
        self.partner._columns.update({
            'property_country': fields.property('res.country', type='many2one', relation="res.country", string="Country by company", view_load=True),
        })
        self.partner._all_columns.update({
            'property_country': fields.column_info('property_country', self.partner._columns['property_country'], None, None, None),
        })
        self.partner._field_create(cr)

        partner_id = self.partner.create(cr, alice, {
            'name': 'An International Partner',
            'email': '*****@*****.**',
            'company_id': parent_company_id,
        })
        self.partner.write(cr, bob, [partner_id], {'property_country': country_fr})
        self.assertEqual(self.partner.browse(cr, bob, partner_id).property_country.id, country_fr, "Bob does not see the value he has set on the property field")

        self.partner.write(cr, alice, [partner_id], {'property_country': country_be})
        self.assertEqual(self.partner.browse(cr, alice, partner_id).property_country.id, country_be, "Alice does not see the value he has set on the property field")
        self.assertEqual(self.partner.browse(cr, bob, partner_id).property_country.id, country_fr, "Changes made by Alice have overwritten Bob's value")
Пример #27
0
    def test_1_property_multicompany(self):
        cr, uid = self.cr, self.uid

        parent_company_id = self.imd.get_object_reference(cr, uid, 'base', 'main_company')[1]
        country_be = self.imd.get_object_reference(cr, uid, 'base', 'be')[1]
        country_fr = self.imd.get_object_reference(cr, uid, 'base', 'fr')[1]
        group_partner_manager = self.imd.get_object_reference(cr, uid, 'base', 'group_partner_manager')[1]
        group_multi_company = self.imd.get_object_reference(cr, uid, 'base', 'group_multi_company')[1]

        sub_company = self.company.create(cr, uid, {'name': 'MegaCorp', 'parent_id': parent_company_id})
        alice = self.user.create(cr, uid, {'name': 'Alice',
            'login':'******',
            'email':'*****@*****.**',
            'company_id':parent_company_id,
            'company_ids':[(6, 0, [parent_company_id, sub_company])],
            'country_id':country_be,
            'groups_id': [(6, 0, [group_partner_manager, group_multi_company])]
        })
        bob = self.user.create(cr, uid, {'name': 'Bob',
            'login':'******',
            'email':'*****@*****.**',
            'company_id':sub_company,
            'company_ids':[(6, 0, [parent_company_id, sub_company])],
            'country_id':country_fr,
            'groups_id': [(6, 0, [group_partner_manager, group_multi_company])]
        })
        
        self.partner._columns = dict(self.partner._columns)
        self.partner._columns.update({
            'property_country': fields.property(type='many2one', relation="res.country", string="Country by company"),
        })
        self.partner._all_columns.update({
            'property_country': fields.column_info('property_country', self.partner._columns['property_country'], None, None, None),
        })
        self.partner._field_create(cr)

        partner_id = self.partner.create(cr, alice, {
            'name': 'An International Partner',
            'email': '*****@*****.**',
            'company_id': parent_company_id,
        })
        self.partner.write(cr, bob, [partner_id], {'property_country': country_fr})
        self.assertEqual(self.partner.browse(cr, bob, partner_id).property_country.id, country_fr, "Bob does not see the value he has set on the property field")

        self.partner.write(cr, alice, [partner_id], {'property_country': country_be})
        self.assertEqual(self.partner.browse(cr, alice, partner_id).property_country.id, country_be, "Alice does not see the value he has set on the property field")
        self.assertEqual(self.partner.browse(cr, bob, partner_id).property_country.id, country_fr, "Changes made by Alice have overwritten Bob's value")
Пример #28
0
class res_partner(osv.osv):
    _name = 'res.partner'
    _inherit = 'res.partner'
    _columns = {
        'property_product_pricelist':
        fields.property(
            type='many2one',
            relation='product.pricelist',
            string="Sale Pricelist",
            help=
            "This pricelist will be used, instead of the default one, for sales to the current partner"
        ),
    }

    def _commercial_fields(self, cr, uid, context=None):
        return super(res_partner, self)._commercial_fields(
            cr, uid, context=context) + ['property_product_pricelist']
Пример #29
0
class saiku_user_properties(orm.Model):
    _name = "saiku.user.properties"
    _columns = {
        'saiku_user_properties_file': fields.property(
            None, type='char', size=300,
            string='Full Path to Saiku User Properties'),
    }

    def _generate_saiku_user_properties(self, cr, uid, context=None):
        res_bi_group = self.pool['ir.model.data'].get_object_reference(
            cr, uid, 'bi_saiku_user_properties',
            'group_business_intelligence')
        if res_bi_group and res_bi_group[0] == 'res.groups':
            bi_group_id = res_bi_group[1]
        else:
            raise orm.except_orm('Error', 'This should never happen')
        bi_user_ids = self.pool['res.groups'].read(
            cr, uid, bi_group_id, ['users'], context=context)['users']
        if bi_user_ids:
            user_prop = u'#This file is auto-generated and kept up-to-date'\
                + u' by OpenERP\n#Username,password,role\n'
            for user in self.pool['res.users'].browse(
                    cr, uid, bi_user_ids, context=context):
                user_prop += u'%s=%s,ROLE_USER' % (user.login, user.password)
                if user.id == SUPERUSER_ID:
                    user_prop += u',ROLE_ADMIN'
                user_prop += u'\n'
            user_properties_file = self.pool['ir.property'].get(
                cr, uid, 'saiku_user_properties_file',
                'saiku.user.properties', context=context)
            if not user_properties_file:
                raise orm.except_orm(
                    'Error:',
                    "No value for property 'Full Path to Saiku User "
                    "Properties'")
            user_file = open(user_properties_file, 'wb')
            user_file.seek(0)
            user_file.write(user_prop)
            user_file.close()
            logger.info(
                "Saiku file '%s' updated"
                % user_properties_file)
        else:
            logger.info('There are no Business Intelligence users in OpenERP')
        return True
Пример #30
0
class product_category(osv.osv):
    _inherit = 'product.category'

    _columns = {
        # Cuenta sobre Notas de venta
        'property_account_income_note_categ':
        fields.property(
            'account.account',
            type='many2one',
            relation='account.account',
            string="Cuenta ingresos por nota de venta",
            view_load=True,
            help=
            "Esta cuenta se utiliza para cuando se aplican notas de venta sobre el cliente."
        ),
    }

    _sql_constraints = []
Пример #31
0
class res_lang(osv.osv):
    _name = "res.lang"
    _inherit = "res.lang"
    _description = "Idiomas"

    _columns = {
        'currency_id':
        fields.many2one('res.currency', 'Currency', required=True),
        'property_product_pricelist':
        fields.property(
            type='many2one',
            relation='product.pricelist',
            domain=[('type', '=', 'sale')],
            string="Sale Pricelist",
            help=
            "This pricelist will be used, instead of the default one, for sales to the current partner"
        ),
    }