panlatent/yii2-odoo

Why we need ActiveRecordTrait?

Closed this issue · 1 comments

Adding it to ActiveRecord removes id and dates from object. Why we need it here?

With it:
you can't access $var->id as it's added as null to the end of app\models\Odoo\CrmTestVariant

app\models\Odoo\CrmTestVariant Object
(
    [_attributes:yii\db\BaseActiveRecord:private] => Array
        (
            [create_date] => 2021-02-06 12:54:41
            [lock_headquarter_discount] => 1
            [write_uid] => Array
                (
                    [0] => 366
                    [1] => XX Dawid
                )
            [ignore_salesman_discount_model] => 1
            [document_pack_number] => 0
            [id] => 1
            [create_uid] => Array
                (
                    [0] => 500
                    [1] => Dawid XX
                )
            [display_name] => a1
            [__last_update] => 2021-02-10 12:55:21
            [document_number_no_visualization] => 10
            [document_number_visualization] => 12
            [description] => Na start nie zawiera udzielonego jakiegokolwiek rabatu
            [lock_client_tab] => 1
            [lock_offer_deadline] => 
            [lock_salesman_discount] => 1
            [write_date] => 2021-02-10 12:55:21
            [test_id] => Array
                (
                    [0] => 1
                    [1] => Mój Prąd
                )
            [lock_salesman_increase] => 1
            [lock_production_tab] => 
            [lock_configuration_tab] => 
            [name] => a1
            [discount_on_start] => 0
            [lock_credit_zero] => 1
        )
    [_oldAttributes:yii\db\BaseActiveRecord:private] => Array
        (
            [create_date] => 2021-02-06 12:54:41
            [lock_headquarter_discount] => 1
            [write_uid] => Array
                (
                    [0] => 366
                    [1] => XX Dawid
                )
            [ignore_salesman_discount_model] => 1
            [document_pack_number] => 0
            [id] => 1
            [create_uid] => Array
                (
                    [0] => 500
                    [1] => Dawid XX
                )
            [display_name] => a1
            [__last_update] => 2021-02-10 12:55:21
            [document_number_no_visualization] => 10
            [document_number_visualization] => 12
            [description] => Na start nie zawiera udzielonego jakiegokolwiek rabatu
            [lock_client_tab] => 1
            [lock_offer_deadline] => 
            [lock_salesman_discount] => 1
            [write_date] => 2021-02-10 12:55:21
            [test_id] => Array
                (
                    [0] => 1
                    [1] => Mój Prąd
                )
            [lock_salesman_increase] => 1
            [lock_production_tab] => 
            [lock_configuration_tab] => 
            [name] => a1
            [discount_on_start] => 0
            [lock_credit_zero] => 1
        )
    [_related:yii\db\BaseActiveRecord:private] => Array
        (
        )
    [_relationsDependencies:yii\db\BaseActiveRecord:private] => Array
        (
        )
    [_errors:yii\base\Model:private] => 
    [_validators:yii\base\Model:private] => 
    [_scenario:yii\base\Model:private] => default
    [_events:yii\base\Component:private] => Array
        (
        )
    [_eventWildcards:yii\base\Component:private] => Array
        (
        )
    [_behaviors:yii\base\Component:private] => Array
        (
        )
    [id] => 
    [create_date] => 
    [write_date] => 
)

Thank you. Use trait to try to cash out of the basic field to support IDE, which can be better reuse. But due to the related functions of BaseActiveRecord, the class attributes cannot take effect. I don't want to introduce additional functions, so the trait will be removed and the property annotation is added to the ActiveRecord.